Class AbstractPythonCodegen
- java.lang.Object
-
- org.openapitools.codegen.DefaultCodegen
-
- org.openapitools.codegen.languages.AbstractPythonCodegen
-
- All Implemented Interfaces:
CodegenConfig
- Direct Known Subclasses:
AbstractPythonConnexionServerCodegen,PythonClientCodegen,PythonFastAPIServerCodegen
public abstract class AbstractPythonCodegen extends DefaultCodegen implements CodegenConfig
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractPythonCodegen.PydanticCoercibleTypePydantic type generator for values that arrive over the wire as strings — server-bound request parameters in path, query, header, and cookie position.protected classAbstractPythonCodegen.PydanticTypeprotected classAbstractPythonCodegen.PythonImports
-
Field Summary
Fields Modifier and Type Field Description protected booleanhasModelsToImportstatic StringMAP_NUMBER_TOprotected StringmapNumberToprotected StringpackageNameprotected StringpackageVersionprotected StringprojectNamestatic StringPYDANTICprotected static Set<String>PYTHON_KEYWORDSprotected Map<Character,String>regexModifiersstatic Set<String>SUPPORTED_NUMBER_MAPPINGS-
Fields inherited from class org.openapitools.codegen.DefaultCodegen
additionalEmbeddedTemplateDirs, additionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, addSuffixToDuplicateOperationNicknames, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, autosetConstants, cliOptions, DefaultFeatureSet, defaultIncludes, defaultToEmptyContainer, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, enumNameMapping, enumUnknownDefaultCase, enumUnknownDefaultCaseName, falseSchema, filesMetadataFilename, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importBaseType, importContainerType, importMapping, injectModelVendorExtensions, inlineSchemaNameMapping, inlineSchemaOption, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, loadDeepObjectIntoItems, modelDocTemplateFiles, modelNameMapping, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, nameMapping, openAPI, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, removeOperationIdPrefixCount, removeOperationIdPrefixDelimiter, reservedWords, reservedWordsMappings, schemaMapping, serverVariables, skipOperationExample, skipOverwrite, skipSortingOperations, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, SPLIT_ON_SEMICOLON_OR_NEWLINE_REGEX, splitOperationsByContentType, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, templateOutputDirs, testPackage, trueSchema, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions, versionMetadataFilename, XML_MIME_PATTERN
-
-
Constructor Summary
Constructors Constructor Description AbstractPythonCodegen()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda>addMustacheLambdas()Preset map builder with commonly used Mustache lambdas.StringaddRegularExpressionDelimiter(String pattern)If the pattern misses the delimiter, add "/" to the beginning and end Otherwise, return the original patternprotected static StringdropDots(String str)StringescapeQuotationMark(String input)Escape single and/or double quote to avoid code injectionStringescapeReservedWord(String name)Return the escaped name of the reserved wordStringescapeUnsafeCharacters(String input)override with any special text escaping logic to handle unsafe characters so as to avoid code injectionprotected StringformatPythonStringLiteral(String defaultValue)Format a string as a Python string literal (single-quoted).GeneratorLanguagegeneratorLanguage()protected StringgetEnumDefaultValue(String defaultValue, String dataType)Normalize enum default values before matching against enum member literals.protected AbstractPythonCodegen.PydanticTypegetPydanticParameterType(CodegenParameter parameter, Set<String> modelImports, Set<String> exampleImports, Set<String> postponedModelImports, Set<String> postponedExampleImports, AbstractPythonCodegen.PythonImports moduleImports, String classname)StringgetSchemaType(io.swagger.v3.oas.models.media.Schema p)returns the OpenAPI type for the property.StringgetTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)Output the language-specific type declaration of the property.booleanisDataTypeString(String dataType)checks if the data should be classified as "string" in enum e.g. double in C# needs to be double-quoted (e.g. "2.8") by treating it as a string In the future, we may rename this function to "isEnumString"StringpatternCorrection(String pattern)Map<String,ModelsMap>postProcessAllModels(Map<String,ModelsMap> objs)voidpostProcessFile(File file, String fileType)Post-process the auto-generated file, e.g. using go-fmt to format the Go code.voidpostProcessModelProperty(CodegenModel model, CodegenProperty property)ModelsMappostProcessModels(ModelsMap objs)OperationsMappostProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)voidpostProcessParameter(CodegenParameter parameter)voidpostProcessPattern(String pattern, Map<String,Object> vendorExtensions)voidprocessOpts()StringsanitizeTag(String tag)Sanitize tagvoidsetMapNumberTo(String mapNumberTo)voidsetPackageName(String packageName)voidsetParameterExampleValue(CodegenParameter p)Return the example value of the parameter.voidsetParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)Return the example value of the parameter.StringtoApiFilename(String name)Return the file name of the ApiStringtoApiName(String name)Output the API (class) name (capitalized) ending with the specified or default suffix Return DefaultApi if name is emptyStringtoApiTestFilename(String name)Return the file name of the Api TestStringtoApiVarName(String name)Return the variable name in the ApiStringtoDefaultValue(io.swagger.v3.oas.models.media.Schema p)Return the default value of the propertyStringtoEnumDefaultValue(CodegenProperty property, String value)Return the enum default value in the language specified formatStringtoEnumValue(String value, String datatype)Return the enum value in the language specified format e.g. status becomes "status"StringtoEnumVariableName(String name, String datatype)StringtoEnumVarName(String name, String datatype)Return the sanitized variable name for enumStringtoExampleValue(io.swagger.v3.oas.models.media.Schema schema)Return the example value of the propertyStringtoModelFilename(String name)Return the capitalized file name of the modelStringtoModelName(String name)Converts the OpenAPI schema name to a model name suitable for the current code generator.StringtoModelTestFilename(String name)Return the capitalized file name of the model testStringtoOperationId(String operationId)Return the operation ID (method name)StringtoParamName(String name)Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.protected StringtoPythonExample(CodegenParameter cp)protected StringtoPythonExample(CodegenProperty cp)protected StringtoPythonLiteral(Object value)protected StringtoPythonStringLiteral(String value)StringtoRegularExpression(String pattern)Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)StringtoVarName(String name)Return the variable name by removing invalid characters and proper escaping if it's a reserved word.protected StringtoVarNameWithoutNameMapping(String name)protected StringunwrapPythonStringLiteral(String value)Ifvalueis already a Python string literal, return the unescaped inner content.voidupdateImportsFromCodegenModel(String modelName, CodegenModel cm, Set<String> imports)Update set of imports from codegen model recursively-
Methods inherited from class org.openapitools.codegen.DefaultCodegen
addAdditionPropertiesToCodeGenModel, addBodyModelSchema, addHeaders, addImport, addImport, addImport, addImportMappedType, addImports, addImports, addImports, addImportsForPropertyType, addImportsToOneOfInterface, additionalEmbeddedTemplateDirs, additionalProperties, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addOption, addParentContainer, addParentFromContainer, addProperties, addRequiredVarsMap, addSwitch, addVars, addVars, addVarsRequiredVarsAdditionalProps, anyPropertyMatches, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildEnumVars, buildLibraryCliOption, cliOptions, contentTypeVariantMediaType, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, convertPropertyToBooleanAndWriteBack, convertPropertyToStringAndWriteBack, convertPropertyToTypeAndWriteBack, createDiscriminator, defaultIncludes, defaultTemplatingEngine, divideOperationsByContentType, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextInSingleQuotes, escapeTextWhileAllowingNewLines, executePostProcessor, fileSuffix, findCommonPrefixOfVars, findMethodResponse, findMethodResponseCode, fromCallback, fromFormProperty, fromModel, fromOperation, fromParameter, fromProperty, fromProperty, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, generatorLanguageVersion, getAdditionalPropertiesName, getAddSuffixToDuplicateOperationNicknames, getAlias, getAllModels, getAllOfDescendants, getCollectionFormat, getCollectionFormat, getCommonSchemaType, getCommonTypeMapping, getConsumesInfo, getContent, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDiscriminatorPropertyType, getDocExtension, getEnumUnknownDefaultCase, getEnumValueForProperty, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getItemsName, getLegacyDiscriminatorBehavior, getLibrary, getModelNameToSchemaCache, getMostInnerItems, getName, getObjectAsStringList, getObjectAsStringListMap, getObjectAsStringMap, getOneOfAnyOfDescendants, getOpenapiGeneratorIgnoreList, getOrGenerateOperationId, getOutputDir, getParameterDataType, getProducesInfo, getPropertyAsStringList, getPropertyAsStringListMap, getPropertyAsStringMap, getReleaseNote, getSchemaAdditionalProperties, getSchemaFromBooleanOrSchema, getSingleSchemaType, getSupportedVendorExtensions, getSymbolName, getTag, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getUseInlineModelResolver, getUseOneOfInterfaces, getUseOpenapiNormalizer, getVersionMetadataFilename, handleConstantParams, handleMethodResponse, handleMethodResponse, handleSpecialCharacters, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, injectModelVendorExtensions, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isDataTypeBinary, isDataTypeFile, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isQuietMode, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isReservedWord, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, isTypeErasedGenerics, isXmlMimeType, languageSpecificPrimitives, lowerCamelCase, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, modifyFeatureSet, nameMapping, needToImport, normalizeVendorExtensionWithStringList, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessEnumVars, postProcessModelsEnum, postProcessResponseWithProperty, postProcessSupportingFileData, postProcessWebhooksWithModels, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, processTestExampleData, removeEnumUnknownDefaultCase, removeImport, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, removeSelfReferenceImports, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, schemaMapping, serverVariableOverrides, setAddProps, setCircularReferences, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnumDiscriminatorDefaultValue, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterEncodingValues, setParameterExamples, setParameterExampleValue, setParameterNullable, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setSplitOperationsByContentType, setStrictSpecBehavior, setTemplatingEngine, setUseOneOfInterfaces, shouldAddImport, shouldOverwrite, SortModelPropertiesByRequiredFlag, SortParametersByRequiredFlag, specVersionGreaterThanOrEqualTo310, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toAllOfName, toAnyOfName, toApiDocFilename, toApiImport, toArrayModelParamName, toBooleanGetter, toDefaultParameterValue, toDefaultParameterValue, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toEnumName, toEnumName, toExamples, toGetter, toInstantiationType, toMediaTypeSchemaName, toModelDocFilename, toModelImport, toModelImportMap, toOneOfName, toSetter, toTestCaseName, typeMapping, unaliasPropertySchema, unaliasSchema, updateAllModels, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updateEnumVarsWithExtensions, updateEnumVarsWithExtensions, updateEnumVarsWithExtensions, updateModelForAnyType, updateModelForComposedSchema, updateModelForInteger, updateModelForNumber, updateModelForObject, updateModelForString, updateOption, updateParameterForString, updatePropertyForAnyType, updatePropertyForArray, updatePropertyForInteger, updatePropertyForMap, updatePropertyForMap, updatePropertyForNumber, updatePropertyForObject, updatePropertyForString, updateRequestBodyForArray, updateRequestBodyForMap, updateRequestBodyForObject, updateRequestBodyForPrimitiveType, updateRequestBodyForString, useCodegenAsMustacheParentContext, vendorExtensions, writePropertyBack
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openapitools.codegen.CodegenConfig
additionalEmbeddedTemplateDirs, additionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, defaultTemplatingEngine, divideOperationsByContentType, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromModel, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generatorLanguageVersion, getAddSuffixToDuplicateOperationNicknames, getDocExtension, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getName, getOpenapiGeneratorIgnoreList, getOutputDir, getReleaseNote, getSupportedVendorExtensions, getTag, getTemplatingEngine, getTypeDeclaration, getUseInlineModelResolver, getUseOpenapiNormalizer, getVersionMetadataFilename, importMapping, injectModelVendorExtensions, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, isTypeErasedGenerics, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, nameMapping, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessResponseWithProperty, postProcessSupportingFileData, postProcessWebhooksWithModels, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, schemaMapping, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toApiDocFilename, toApiImport, toBooleanGetter, toGetter, toModelDocFilename, toModelImport, toModelImportMap, toSetter, typeMapping, unaliasSchema, updateAllModels, vendorExtensions
-
-
-
-
Field Detail
-
MAP_NUMBER_TO
public static final String MAP_NUMBER_TO
- See Also:
- Constant Field Values
-
PYDANTIC
public static final String PYDANTIC
- See Also:
- Constant Field Values
-
packageName
protected String packageName
-
packageVersion
protected String packageVersion
-
projectName
protected String projectName
-
hasModelsToImport
protected boolean hasModelsToImport
-
mapNumberTo
protected String mapNumberTo
-
-
Method Detail
-
processOpts
public void processOpts()
- Specified by:
processOptsin interfaceCodegenConfig- Overrides:
processOptsin classDefaultCodegen
-
escapeReservedWord
public String escapeReservedWord(String name)
Description copied from class:DefaultCodegenReturn the escaped name of the reserved word- Specified by:
escapeReservedWordin interfaceCodegenConfig- Overrides:
escapeReservedWordin classDefaultCodegen- Parameters:
name- the name to be escaped- Returns:
- the escaped reserved word
throws Runtime exception as reserved word is not allowed (default behavior)
-
toDefaultValue
public String toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
Return the default value of the property- Overrides:
toDefaultValuein classDefaultCodegen- Parameters:
p- OpenAPI property object- Returns:
- string presentation of the default value of the property
-
formatPythonStringLiteral
protected String formatPythonStringLiteral(String defaultValue)
Format a string as a Python string literal (single-quoted). Shared by plain string and string-enum default value paths intoDefaultValue(Schema).
-
unwrapPythonStringLiteral
protected String unwrapPythonStringLiteral(String value)
Ifvalueis already a Python string literal, return the unescaped inner content. Used when reconciling quoted defaults fromtoDefaultValue(Schema)with enum-var matching ingetEnumDefaultValue(String, String).
-
getEnumDefaultValue
protected String getEnumDefaultValue(String defaultValue, String dataType)
Normalize enum default values before matching against enum member literals.toDefaultValue(Schema)now quotes string-enum defaults (e.g.'B'), butupdateCodegenPropertyEnumcompares against unquoted enum values viatoEnumValue. Unwrap first so model properties still resolve to EnumClass.MEMBER.- Overrides:
getEnumDefaultValuein classDefaultCodegen
-
toVarName
public String toVarName(String name)
Description copied from class:DefaultCodegenReturn the variable name by removing invalid characters and proper escaping if it's a reserved word.- Overrides:
toVarNamein classDefaultCodegen- Parameters:
name- the variable name- Returns:
- the sanitized variable name
-
toRegularExpression
public String toRegularExpression(String pattern)
Description copied from class:DefaultCodegenReturn the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)- Overrides:
toRegularExpressionin classDefaultCodegen- Parameters:
pattern- the pattern (regular expression)- Returns:
- properly-escaped pattern
-
toParamName
public String toParamName(String name)
Description copied from class:DefaultCodegenReturn the parameter name by removing invalid characters and proper escaping if it's a reserved word.- Specified by:
toParamNamein interfaceCodegenConfig- Overrides:
toParamNamein classDefaultCodegen- Parameters:
name- Codegen property object- Returns:
- the sanitized parameter name
-
toOperationId
public String toOperationId(String operationId)
Description copied from class:DefaultCodegenReturn the operation ID (method name)- Overrides:
toOperationIdin classDefaultCodegen- Parameters:
operationId- operation ID- Returns:
- the sanitized method name
-
escapeQuotationMark
public String escapeQuotationMark(String input)
Description copied from class:DefaultCodegenEscape single and/or double quote to avoid code injection- Specified by:
escapeQuotationMarkin interfaceCodegenConfig- Overrides:
escapeQuotationMarkin classDefaultCodegen- Parameters:
input- String to be cleaned up- Returns:
- string with quotation mark removed or escaped
-
escapeUnsafeCharacters
public String escapeUnsafeCharacters(String input)
Description copied from class:DefaultCodegenoverride with any special text escaping logic to handle unsafe characters so as to avoid code injection- Specified by:
escapeUnsafeCharactersin interfaceCodegenConfig- Overrides:
escapeUnsafeCharactersin classDefaultCodegen- Parameters:
input- String to be cleaned up- Returns:
- string with unsafe characters removed or escaped
-
postProcessFile
public void postProcessFile(File file, String fileType)
Description copied from class:DefaultCodegenPost-process the auto-generated file, e.g. using go-fmt to format the Go code. The file type can be "model-test", "model-doc", "model", "api", "api-test", "api-doc", "supporting-file", "openapi-generator-ignore", "openapi-generator-version"TODO: store these values in enum instead
- Specified by:
postProcessFilein interfaceCodegenConfig- Overrides:
postProcessFilein classDefaultCodegen- Parameters:
file- file to be processedfileType- file type
-
toExampleValue
public String toExampleValue(io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenReturn the example value of the propertyThis method should be overridden in the generator to meet its requirement.
- Overrides:
toExampleValuein classDefaultCodegen- Parameters:
schema- Property schema- Returns:
- string presentation of the example value of the property
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter p)
Description copied from class:DefaultCodegenReturn the example value of the parameter.- Overrides:
setParameterExampleValuein classDefaultCodegen- Parameters:
p- Codegen parameter
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)
Description copied from class:DefaultCodegenReturn the example value of the parameter.- Overrides:
setParameterExampleValuein classDefaultCodegen- Parameters:
codegenParameter- Codegen parameterparameter- Parameter
-
toPythonExample
protected String toPythonExample(CodegenProperty cp)
-
toPythonExample
protected String toPythonExample(CodegenParameter cp)
-
sanitizeTag
public String sanitizeTag(String tag)
Description copied from class:DefaultCodegenSanitize tag- Specified by:
sanitizeTagin interfaceCodegenConfig- Overrides:
sanitizeTagin classDefaultCodegen- Parameters:
tag- Tag- Returns:
- Sanitized tag
-
setPackageName
public void setPackageName(String packageName)
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegenOutput the language-specific type declaration of the property.- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Overrides:
getTypeDeclarationin classDefaultCodegen- Parameters:
p- property schema- Returns:
- a string presentation of the property type
-
getSchemaType
public String getSchemaType(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegenreturns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type- Overrides:
getSchemaTypein classDefaultCodegen- Parameters:
p- property schema- Returns:
- string presentation of the type
-
toModelName
public String toModelName(String name)
Description copied from class:DefaultCodegenConverts the OpenAPI schema name to a model name suitable for the current code generator. May be overridden for each programming language. In case the name belongs to the TypeSystem it won't be renamed.- Specified by:
toModelNamein interfaceCodegenConfig- Overrides:
toModelNamein classDefaultCodegen- Parameters:
name- the name of the model- Returns:
- capitalized model name
-
toModelFilename
public String toModelFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model- Specified by:
toModelFilenamein interfaceCodegenConfig- Overrides:
toModelFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
toModelTestFilename
public String toModelTestFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model test- Specified by:
toModelTestFilenamein interfaceCodegenConfig- Overrides:
toModelTestFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
toApiFilename
public String toApiFilename(String name)
Description copied from class:DefaultCodegenReturn the file name of the Api- Specified by:
toApiFilenamein interfaceCodegenConfig- Overrides:
toApiFilenamein classDefaultCodegen- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toApiTestFilename
public String toApiTestFilename(String name)
Description copied from class:DefaultCodegenReturn the file name of the Api Test- Specified by:
toApiTestFilenamein interfaceCodegenConfig- Overrides:
toApiTestFilenamein classDefaultCodegen- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toApiName
public String toApiName(String name)
Description copied from class:DefaultCodegenOutput the API (class) name (capitalized) ending with the specified or default suffix Return DefaultApi if name is empty- Specified by:
toApiNamein interfaceCodegenConfig- Overrides:
toApiNamein classDefaultCodegen- Parameters:
name- the name of the Api- Returns:
- capitalized Api name
-
toApiVarName
public String toApiVarName(String name)
Description copied from class:DefaultCodegenReturn the variable name in the Api- Specified by:
toApiVarNamein interfaceCodegenConfig- Overrides:
toApiVarNamein classDefaultCodegen- Parameters:
name- the variable name of the Api- Returns:
- the snake-cased variable name
-
generatorLanguage
public GeneratorLanguage generatorLanguage()
- Specified by:
generatorLanguagein interfaceCodegenConfig- Overrides:
generatorLanguagein classDefaultCodegen
-
addMustacheLambdas
protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda> addMustacheLambdas()
Description copied from class:DefaultCodegenPreset map builder with commonly used Mustache lambdas. To extend the map, override addMustacheLambdas(), call parent method first and then add additional lambdas to the returned builder. If common lambdas are not desired, override addMustacheLambdas() method and return empty builder. Corresponding user documentation: docs/templating.md, section "Mustache Lambdas"- Overrides:
addMustacheLambdasin classDefaultCodegen- Returns:
- preinitialized map with common lambdas
-
postProcessAllModels
public Map<String,ModelsMap> postProcessAllModels(Map<String,ModelsMap> objs)
- Specified by:
postProcessAllModelsin interfaceCodegenConfig- Overrides:
postProcessAllModelsin classDefaultCodegen
-
setMapNumberTo
public void setMapNumberTo(String mapNumberTo)
-
updateImportsFromCodegenModel
public void updateImportsFromCodegenModel(String modelName, CodegenModel cm, Set<String> imports)
Update set of imports from codegen model recursively- Parameters:
modelName- model namecm- codegen modelimports- set of imports
-
postProcessOperationsWithModels
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)
- Specified by:
postProcessOperationsWithModelsin interfaceCodegenConfig- Overrides:
postProcessOperationsWithModelsin classDefaultCodegen
-
getPydanticParameterType
protected AbstractPythonCodegen.PydanticType getPydanticParameterType(CodegenParameter parameter, Set<String> modelImports, Set<String> exampleImports, Set<String> postponedModelImports, Set<String> postponedExampleImports, AbstractPythonCodegen.PythonImports moduleImports, String classname)
-
postProcessParameter
public void postProcessParameter(CodegenParameter parameter)
- Specified by:
postProcessParameterin interfaceCodegenConfig- Overrides:
postProcessParameterin classDefaultCodegen
-
postProcessModelProperty
public void postProcessModelProperty(CodegenModel model, CodegenProperty property)
- Specified by:
postProcessModelPropertyin interfaceCodegenConfig- Overrides:
postProcessModelPropertyin classDefaultCodegen
-
postProcessPattern
public void postProcessPattern(String pattern, Map<String,Object> vendorExtensions)
-
addRegularExpressionDelimiter
public String addRegularExpressionDelimiter(String pattern)
Description copied from class:DefaultCodegenIf the pattern misses the delimiter, add "/" to the beginning and end Otherwise, return the original pattern- Overrides:
addRegularExpressionDelimiterin classDefaultCodegen- Parameters:
pattern- the pattern (regular expression)- Returns:
- the pattern with delimiter
-
postProcessModels
public ModelsMap postProcessModels(ModelsMap objs)
- Specified by:
postProcessModelsin interfaceCodegenConfig- Overrides:
postProcessModelsin classDefaultCodegen
-
toEnumVarName
public String toEnumVarName(String name, String datatype)
Description copied from class:DefaultCodegenReturn the sanitized variable name for enum- Overrides:
toEnumVarNamein classDefaultCodegen- Parameters:
name- enum variable namedatatype- data type- Returns:
- the sanitized variable name for enum
-
toEnumValue
public String toEnumValue(String value, String datatype)
Description copied from class:DefaultCodegenReturn the enum value in the language specified format e.g. status becomes "status"- Overrides:
toEnumValuein classDefaultCodegen- Parameters:
value- enum variable namedatatype- data type- Returns:
- the sanitized value for enum
-
toEnumDefaultValue
public String toEnumDefaultValue(CodegenProperty property, String value)
Description copied from class:DefaultCodegenReturn the enum default value in the language specified format- Overrides:
toEnumDefaultValuein classDefaultCodegen- Parameters:
property- The codegen property to create the default for.value- Enum variable name- Returns:
- the default value for the enum
-
isDataTypeString
public boolean isDataTypeString(String dataType)
checks if the data should be classified as "string" in enum e.g. double in C# needs to be double-quoted (e.g. "2.8") by treating it as a string In the future, we may rename this function to "isEnumString"- Overrides:
isDataTypeStringin classDefaultCodegen- Parameters:
dataType- data type- Returns:
- true if it's a enum string
-
-