Feature request: strict(er) validation option
Created by: wheezil
Description
It is all too easy, especially for newbies, to write OpenAPI specifications that look good but which are incorrect, for example trying to use "long" or "date" as types instead of formats for string. This results in unexpected generated code and incorrect specification relative to intent. While the generator does issue warnings to the logger, these messages are easy to miss or ignore especially with verbose output.
openapi-generator version
3.3.0
OpenAPI declaration file content or url
N/A
Command line used for generation
N/A
Steps to reproduce
Process any OpenAPI file containing invalid types in a model. For example:
"Test": {
"properties": {
"date": {
"type": "date",
"default":"2001-01-01"
},
"thing":{
"$ref":"#/components/schemas/Thing"
}
}
}
Related issues/PRs
Suggest a fix/enhancement
Suggestion: implement a --strict command-line option, which will convert all (or many) LOGGER.warn() calls into exceptions. I have identified these cases in DefaultCodegen.java:
1195: LOGGER.warn("Multiple MediaTypes found, using only the first one");
1319: LOGGER.warn("Error obtaining the datatype from ref:" + schema.get$ref() + ". Default to 'object'");
1360: LOGGER.warn("Unknown `format` detected for " + schema.getName() + ": " + schema.getFormat());
1379: LOGGER.warn("Unknown type found in the schema: " + schema.getType());
1520: LOGGER.warn("Schema {} not found", name);
1578: LOGGER.warn("More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored.");
2067: LOGGER.warn("skipping invalid map property " + Json.pretty(property));
2436: LOGGER.warn("Unknown parameter type " + p.baseType + " for " + p.baseName);
2738: LOGGER.warn("warning! Schema not found for parameter \"" + parameter.getName() + "\", using String");
2756: LOGGER.warn("warning! No inner type supplied for array parameter \"" + parameter.getName() + "\", using String");
2977: LOGGER.warn("Unknown parameter type: " + parameter.getName());
2140: LOGGER.warn("Empty operationId found for path: " + httpMethod + " " + path + ". Renamed to auto-generated operationId: " + operationId);
3375: LOGGER.warn("null property for " + key);
4280: LOGGER.warn("warning! No inner type supplied for array parameter \"" + s.getName() + "\", using String");
4298: LOGGER.warn("Could not compute datatypeWithEnum from " + codegenParameter.baseType + ", " + codegenParameter.enumName);
4538: LOGGER.warn("The following schema has undefined (null) baseType. " +