public class PythonClientCodegen extends PythonLegacyClientCodegen
apiDocPath, DEFAULT_LIBRARY, modelDocPath, PACKAGE_URL, packageName, packageUrl, packageVersion, projectName, RECURSION_LIMIT, regexModifiers, USE_NOSE, useNoseadditionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, DefaultFeatureSet, defaultIncludes, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importMapping, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, openAPI, outputFolder, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, reservedWords, reservedWordsMappings, serverVariables, skipOverwrite, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, testPackage, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions| Constructor and Description |
|---|
PythonClientCodegen() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel,
io.swagger.v3.oas.models.media.Schema schema)
Handle the model for the 'additionalProperties' keyword in the OAS schema.
|
protected void |
addBodyModelSchema(CodegenParameter codegenParameter,
String name,
io.swagger.v3.oas.models.media.Schema schema,
Set<String> imports,
String bodyParameterName,
boolean forceSimpleRef)
Adds the body model schema to the body parameter
We have a custom version of this method so we can flip forceSimpleRef
to True based upon the results of unaliasSchema
With this customization, we ensure that when schemas are passed to getSchemaType
- if they have ref in them they are a model
- if they do not have ref in them they are not a model
|
protected void |
addParentContainer(CodegenModel model,
String name,
io.swagger.v3.oas.models.media.Schema schema)
Sets the value of the 'model.parent' property in CodegenModel
We have a custom version of this function so we can add the dataType on the ArrayModel
|
CodegenParameter |
fromFormProperty(String name,
io.swagger.v3.oas.models.media.Schema propertySchema,
Set<String> imports)
Create a CodegenParameter for a Form Property
We have a custom version of this method so we can invoke
setParameterExampleValue(codegenParameter, parameter)
rather than setParameterExampleValue(codegenParameter)
This ensures that all of our samples are generated in
toExampleValueRecursive
|
CodegenModel |
fromModel(String name,
io.swagger.v3.oas.models.media.Schema sc)
Convert OAS Model object to Codegen Model object
We have a custom version of this method so we can:
- set the correct regex values for requiredVars + optionalVars
- set model.defaultValue and model.hasRequired per the three use cases defined in this method
|
CodegenProperty |
fromProperty(String name,
io.swagger.v3.oas.models.media.Schema p)
Convert OAS Property object to Codegen Property object
We have a custom version of this method to always set allowableValues.enumVars on all enum variables
Together with unaliasSchema this sets primitive types with validations as models
This method is used by fromResponse
|
CodegenParameter |
fromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody body,
Set<String> imports,
String bodyParameterName)
We have a custom version of this method to produce links to models when they are
primitive type (not map, not array, not object) and include validations or are enums
|
String |
getModelName(io.swagger.v3.oas.models.media.Schema sc) |
protected Map<String,io.swagger.v3.oas.models.media.Schema> |
getModelNameToSchemaCache()
Return a map from model name to Schema for efficient lookup.
|
String |
getName()
Configures a friendly name for the generator.
|
protected Object |
getObjectExample(io.swagger.v3.oas.models.media.Schema sc)
Gets an example if it exists
|
String |
getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
Returns the python type for the property.
|
String |
getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Output the type declaration of a given name
|
Map<String,Object> |
postProcessAllModels(Map<String,Object> objs)
Override with special post-processing for all models.
|
void |
postProcessModelProperty(CodegenModel model,
CodegenProperty p) |
Map<String,Object> |
postProcessOperationsWithModels(Map<String,Object> objs,
List<Object> allModels) |
void |
postProcessParameter(CodegenParameter p) |
void |
processOpts() |
String |
pythonDate(Object dateValue) |
String |
pythonDateTime(Object dateTimeValue) |
void |
setParameterExampleValue(CodegenParameter codegenParameter,
io.swagger.v3.oas.models.parameters.Parameter parameter)
Set the codegenParameter example value
We have a custom version of this function so we can invoke toExampleValue
|
void |
setParameterExampleValue(CodegenParameter codegenParameter,
io.swagger.v3.oas.models.parameters.RequestBody requestBody)
Return the example value of the parameter.
|
String |
toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
Return the default value of the property
|
String |
toEnumValue(String value,
String datatype)
Return the enum value in the language specified format
e.g.
|
String |
toEnumVarName(String value,
String datatype)
Return the sanitized variable name for enum
|
String |
toExampleValue(io.swagger.v3.oas.models.media.Schema schema,
Object objExample) |
String |
toInstantiationType(io.swagger.v3.oas.models.media.Schema property)
Return the instantiation type of the property, especially for map and array
|
String |
toModelImport(String name)
Return the fully-qualified "Model" name for import
|
io.swagger.v3.oas.models.media.Schema |
unaliasSchema(io.swagger.v3.oas.models.media.Schema schema,
Map<String,String> usedImportMappings) |
void |
updateCodegenPropertyEnum(CodegenProperty var)
Update codegen property's enum by adding "enumVars" (with name and value)
|
addRegularExpressionDelimiter, apiDocFileFolder, apiFileFolder, apiTestFileFolder, dropDots, escapeQuotationMark, escapeReservedWord, escapeUnsafeCharacters, generatePackageName, getHelp, getTag, modelDocFileFolder, modelFileFolder, modelTestFileFolder, packagePath, patternCorrection, postProcessFile, postProcessModels, postProcessPattern, sanitizeTag, setPackageName, setPackageUrl, setPackageVersion, setParameterExampleValue, setProjectName, setUseNose, toApiDocFilename, toApiFilename, toApiName, toApiTestFilename, toApiVarName, toExampleValue, toModelDocFilename, toModelFilename, toModelName, toModelTestFilename, toOperationId, toParamName, toRegularExpression, toVarNameaddHeaders, addImport, addImportsToOneOfInterface, additionalProperties, addMustacheLambdas, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addProperties, addSwitch, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, createDiscriminator, defaultIncludes, embeddedTemplateDir, encodePath, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromOperation, fromParameter, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, getAdditionalProperties, getAlias, getAllModels, getAllOfDescendants, getAllowUnicodeIdentifiers, getApiNamePrefix, getApiNameSuffix, getCollectionFormat, getCollectionFormat, getConsumesInfo, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDocExtension, getEnsureUniqueParams, getFeatureSet, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getLegacyDiscriminatorBehavior, getLibrary, getModelNamePrefix, getModelNameSuffix, getMostInnerItems, getOneOfAnyOfDescendants, getOrGenerateOperationId, getOutputDir, getParameterDataType, getPrependFormOrBodyParameters, getProducesInfo, getReleaseNote, getSchemaAdditionalProperties, getSchemaItems, getSingleSchemaType, getSortModelPropertiesByRequiredFlag, getSortParamsByRequiredFlag, getSymbolName, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getUseOneOfInterfaces, handleMethodResponse, handleMethodResponse, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, instantiationTypes, isAnyTypeSchema, isDataTypeBinary, isDataTypeFile, isDataTypeString, isEnableMinimalUpdate, isEnablePostProcessFile, isFreeFormObject, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isReservedWord, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, lowerCamelCase, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestTemplateFiles, modifyFeatureSet, needToImport, outputFolder, postProcess, postProcessModelsEnum, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, serverVariableOverrides, setAllowUnicodeIdentifiers, setApiNamePrefix, setApiNameSuffix, setApiPackage, setCircularReferences, setDisallowAdditionalPropertiesIfNotPresent, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnsureUniqueParams, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLegacyDiscriminatorBehavior, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterContentType, setParameterNullable, setPrependFormOrBodyParameters, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOverwrite, setSortModelPropertiesByRequiredFlag, setSortParamsByRequiredFlag, setStrictSpecBehavior, setTemplateDir, setTemplatingEngine, setUseOneOfInterfaces, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toAllOfName, toAnyOfName, toApiImport, toArrayModelParamName, toBooleanGetter, toDefaultValueWithParam, toEnumDefaultValue, toEnumName, toExamples, toGetter, toModelImportMap, toOneOfName, toSetter, typeMapping, updateAllModels, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updateEnumVarsWithExtensions, updateOption, updatePropertyForArray, updatePropertyForMap, vendorExtensions, writePropertyBackclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadditionalProperties, addOperationToGroup, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, embeddedTemplateDir, encodePath, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, getDocExtension, getFeatureSet, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getOutputDir, getReleaseNote, getTemplatingEngine, getTypeDeclaration, importMapping, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestTemplateFiles, outputFolder, postProcess, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOverwrite, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toApiImport, toBooleanGetter, toGetter, toModelImportMap, toSetter, typeMapping, updateAllModels, vendorExtensionspublic void processOpts()
processOpts in interface CodegenConfigprocessOpts in class PythonLegacyClientCodegenpublic String getName()
getName in interface CodegenConfiggetName in class PythonLegacyClientCodegenpublic io.swagger.v3.oas.models.media.Schema unaliasSchema(io.swagger.v3.oas.models.media.Schema schema,
Map<String,String> usedImportMappings)
unaliasSchema in interface CodegenConfigunaliasSchema in class DefaultCodegenpublic String toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
toDefaultValue in class PythonLegacyClientCodegenp - OpenAPI property objectpublic String toModelImport(String name)
DefaultCodegentoModelImport in interface CodegenConfigtoModelImport in class PythonLegacyClientCodegenname - the name of the "Model"public Map<String,Object> postProcessOperationsWithModels(Map<String,Object> objs, List<Object> allModels)
postProcessOperationsWithModels in interface CodegenConfigpostProcessOperationsWithModels in class DefaultCodegenpublic Map<String,Object> postProcessAllModels(Map<String,Object> objs)
postProcessAllModels in interface CodegenConfigpostProcessAllModels in class DefaultCodegenobjs - a map going from the model name to a object hoding the model infopublic CodegenProperty fromProperty(String name, io.swagger.v3.oas.models.media.Schema p)
fromProperty in class DefaultCodegenname - name of the propertyp - OAS property objectpublic void updateCodegenPropertyEnum(CodegenProperty var)
updateCodegenPropertyEnum in class DefaultCodegenvar - list of CodegenPropertypublic CodegenParameter fromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody body, Set<String> imports, String bodyParameterName)
fromRequestBody in class DefaultCodegenbody - requesst bodyimports - import collectionbodyParameterName - body parameter nameprotected void addBodyModelSchema(CodegenParameter codegenParameter, String name, io.swagger.v3.oas.models.media.Schema schema, Set<String> imports, String bodyParameterName, boolean forceSimpleRef)
addBodyModelSchema in class DefaultCodegencodegenParameter - the body parametername - model schema ref key in componentsschema - the model schema (not refed)imports - collection of importsbodyParameterName - body parameter nameforceSimpleRef - if true use a model referencepublic String toEnumVarName(String value, String datatype)
toEnumVarName in class DefaultCodegenvalue - enum variable namedatatype - data typepublic String toEnumValue(String value, String datatype)
toEnumValue in class DefaultCodegenvalue - enum variable namedatatype - data typepublic void postProcessModelProperty(CodegenModel model, CodegenProperty p)
postProcessModelProperty in interface CodegenConfigpostProcessModelProperty in class PythonLegacyClientCodegenpublic void postProcessParameter(CodegenParameter p)
postProcessParameter in interface CodegenConfigpostProcessParameter in class PythonLegacyClientCodegenprotected void addParentContainer(CodegenModel model, String name, io.swagger.v3.oas.models.media.Schema schema)
addParentContainer in class DefaultCodegenmodel - the codegen representation of the OAS schema.name - the name of the model.schema - the input OAS schema.public CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema sc)
fromModel in interface CodegenConfigfromModel in class DefaultCodegenname - the name of the modelsc - OAS Model objectpublic String getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
getSchemaType in class PythonLegacyClientCodegenschema - property schemapublic String getModelName(io.swagger.v3.oas.models.media.Schema sc)
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
getTypeDeclaration in interface CodegenConfiggetTypeDeclaration in class PythonLegacyClientCodegenp - property schemapublic String toInstantiationType(io.swagger.v3.oas.models.media.Schema property)
DefaultCodegentoInstantiationType in class DefaultCodegenproperty - property schemaprotected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)
DefaultCodegenaddAdditionPropertiesToCodeGenModel in class DefaultCodegencodegenModel - The codegen representation of the schema.schema - The input OAS schema.protected Object getObjectExample(io.swagger.v3.oas.models.media.Schema sc)
sc - input schemapublic String toExampleValue(io.swagger.v3.oas.models.media.Schema schema, Object objExample)
public void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)
setParameterExampleValue in class PythonLegacyClientCodegencodegenParameter - the item we are setting the example onparameter - the base parameter that came from the specpublic void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.RequestBody requestBody)
setParameterExampleValue in class DefaultCodegencodegenParameter - Codegen parameterrequestBody - Request bodypublic CodegenParameter fromFormProperty(String name, io.swagger.v3.oas.models.media.Schema propertySchema, Set<String> imports)
fromFormProperty in class DefaultCodegenname - the property namepropertySchema - the property schemaimports - our import setprotected Map<String,io.swagger.v3.oas.models.media.Schema> getModelNameToSchemaCache()
getModelNameToSchemaCache in class DefaultCodegenCopyright © 2021. All rights reserved.