Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit fee246a

Browse files
committed
Adds new command line argument nonCompliantUseDiscriminatorIfCompositionFails
1 parent 8a1ce13 commit fee246a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,4 +404,14 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
404404

405405
public static final String ERROR_OBJECT_TYPE = "errorObjectType";
406406

407+
public static final String NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS = "nonCompliantUseDiscriminatorIfCompositionFails";
408+
409+
public static final String NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS_DESC =
410+
"When true, If the payload fails to validate against composed schemas (allOf/anyOf/oneOf/not) and a discriminator is present, " +
411+
"then ignore the compostion validation errors and attempt to use the discriminator to validate the payload. " +
412+
"Note: setting this to true makes the generated client not comply with json schema because it ignores compotion validation errors . " +
413+
"Please consider making your schemas more restrictive rather than setting this to true. You can do that by: " +
414+
"- defining the propertyName as an enum with only one value in the schemas that are in your discriminator map" +
415+
"- setting additionalProperties: false in your schemas";
416+
407417
}

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ public PythonClientCodegen() {
215215
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
216216
cliOptions.add(CliOption.newBoolean(USE_INLINE_MODEL_RESOLVER, "use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used").
217217
defaultValue(Boolean.FALSE.toString()));
218+
CliOption nonCompliantUseDiscrIfCompositionFails = CliOption.newBoolean(CodegenConstants.NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS, CodegenConstants.NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS_DESC);
219+
cliOptions.add(nonCompliantUseDiscrIfCompositionFails);
218220

219221
supportedLibraries.put("urllib3", "urllib3-based client");
220222
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use: urllib3");

0 commit comments

Comments
 (0)