From ce4a6a37c6ee0432a81874e909a40d1537777ce8 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 22 Jul 2023 15:29:04 +0800 Subject: [PATCH] add oneOf lookup option in python client generator (#16154) --- docs/generators/python.md | 1 + .../org/openapitools/codegen/languages/PythonClientCodegen.java | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/generators/python.md b/docs/generators/python.md index 0f9b2da65c3..84a01d4f301 100644 --- a/docs/generators/python.md +++ b/docs/generators/python.md @@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |packageVersion|python package version.| |1.0.0| |projectName|python project name in setup.py (e.g. petstore-api).| |null| |recursionLimit|Set the recursion limit. If not set, use the system default value.| |null| +|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false| ## IMPORT MAPPING diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index d505891283f..a67ccc7d47b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -180,6 +180,7 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege .defaultValue("%Y-%m-%dT%H:%M:%S%z")); cliOptions.add(new CliOption(DATE_FORMAT, "date format for query parameters") .defaultValue("%Y-%m-%d")); + cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false")); supportedLibraries.put("urllib3", "urllib3-based client"); supportedLibraries.put("asyncio", "asyncio-based client");