Class DefaultCodegen
- java.lang.Object
-
- org.openapitools.codegen.DefaultCodegen
-
- All Implemented Interfaces:
CodegenConfig
- Direct Known Subclasses:
AbstractAdaCodegen,AbstractApexCodegen,AbstractCppCodegen,AbstractCSharpCodegen,AbstractDartCodegen,AbstractEiffelCodegen,AbstractFSharpCodegen,AbstractGoCodegen,AbstractGraphQLCodegen,AbstractJavaCodegen,AbstractJuliaCodegen,AbstractKotlinCodegen,AbstractPhpCodegen,AbstractPythonCodegen,AbstractRubyCodegen,AbstractRustCodegen,AbstractScalaCodegen,AbstractTypeScriptClientCodegen,AndroidClientCodegen,Apache2ConfigCodegen,AsciidocDocumentationCodegen,AvroSchemaCodegen,BashClientCodegen,CLibcurlClientCodegen,ClojureClientCodegen,ConfluenceWikiCodegen,CrystalClientCodegen,ElixirClientCodegen,ElmClientCodegen,ErlangClientCodegen,ErlangProperCodegen,ErlangServerCodegen,HaskellHttpClientCodegen,HaskellServantCodegen,HaskellYesodServerCodegen,JavascriptApolloClientCodegen,JavascriptClientCodegen,JavascriptClosureAngularClientCodegen,JetbrainsHttpClientClientCodegen,JMeterClientCodegen,K6ClientCodegen,LuaClientCodegen,MarkdownDocumentationCodegen,MysqlSchemaCodegen,N4jsClientCodegen,NimClientCodegen,NodeJSExpressServerCodegen,ObjcClientCodegen,OCamlClientCodegen,OpenAPIGenerator,OpenAPIYamlGenerator,PerlClientCodegen,PhpSilexServerCodegen,PlantumlDocumentationCodegen,PostmanCollectionCodegen,PowerShellClientCodegen,ProtobufSchemaCodegen,RClientCodegen,ScalaFinchServerCodegen,StaticDocCodegen,StaticHtml2Generator,StaticHtmlGenerator,Swift5ClientCodegen,SwiftCombineClientCodegen,WsdlSchemaCodegen,XojoClientCodegen,ZapierClientCodegen
public class DefaultCodegen extends Object implements CodegenConfig
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DefaultCodegen()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)Handle the model for the 'additionalProperties' keyword in the OAS schema.protected voidaddBodyModelSchema(CodegenParameter codegenParameter, String name, io.swagger.v3.oas.models.media.Schema schema, Set<String> imports, String bodyParameterName, boolean forceSimpleRef)protected voidaddHeaders(io.swagger.v3.oas.models.responses.ApiResponse response, List<CodegenProperty> properties)Add headers to codegen propertyprotected voidaddImport(io.swagger.v3.oas.models.media.ComposedSchema composed, io.swagger.v3.oas.models.media.Schema childSchema, CodegenModel model, String modelName)Add the model name of the child schema in a composed schema to the set of importsprotected voidaddImport(Set<String> importsToBeAddedTo, String type)protected voidaddImport(CodegenModel m, String type)protected voidaddImports(Set<String> importsToBeAddedTo, Set<String> importsToAdd)protected voidaddImports(Set<String> importsToBeAddedTo, IJsonSchemaValidationProperties type)protected voidaddImports(CodegenModel m, IJsonSchemaValidationProperties type)protected voidaddImportsForPropertyType(CodegenModel model, CodegenProperty property)For a given property, adds all needed imports to the model This includes a flat property type (e.g.voidaddImportsToOneOfInterface(List<Map<String,String>> imports)Map<String,Object>additionalProperties()protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda>addMustacheLambdas()Preset map builder with commonly used Mustache lambdas.voidaddOneOfInterfaceModel(io.swagger.v3.oas.models.media.ComposedSchema cs, String type)Add a given ComposedSchema as an interface model to be generated, assuming it has `oneOf` definedvoidaddOneOfNameExtension(io.swagger.v3.oas.models.media.ComposedSchema s, String name)Add "x-one-of-name" extension to a given oneOf schema (assuming it has at least 1 oneOf elements)voidaddOperationToGroup(String tag, String resourcePath, io.swagger.v3.oas.models.Operation operation, CodegenOperation co, Map<String,List<CodegenOperation>> operations)Add operation to groupprotected voidaddOption(String key, String description, String defaultValue)protected voidaddOption(String key, String description, String defaultValue, Map<String,String> enumValues)protected voidaddParentContainer(CodegenModel model, String name, io.swagger.v3.oas.models.media.Schema schema)Sets the value of the 'model.parent' property in CodegenModel, based on the value of the 'additionalProperties' keyword.protected voidaddProperties(Map<String,io.swagger.v3.oas.models.media.Schema> properties, List<String> required, io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)Add schema's properties to "properties" and "required" listStringaddRegularExpressionDelimiter(String pattern)If the pattern misses the delimiter, add "/" to the beginning and end Otherwise, return the original patternprotected voidaddRequiredVarsMap(io.swagger.v3.oas.models.media.Schema schema, IJsonSchemaValidationProperties property)protected voidaddSwitch(String key, String description, Boolean defaultValue)protected voidaddVars(CodegenModel m, Map<String,io.swagger.v3.oas.models.media.Schema> properties, List<String> required, Map<String,io.swagger.v3.oas.models.media.Schema> allProperties, List<String> allRequired)protected voidaddVars(IJsonSchemaValidationProperties m, List<CodegenProperty> vars, Map<String,io.swagger.v3.oas.models.media.Schema> properties, Set<String> mandatory)Add variables (properties) to codegen model (list of properties, various flags, etc)protected voidaddVarsRequiredVarsAdditionalProps(io.swagger.v3.oas.models.media.Schema schema, IJsonSchemaValidationProperties property)StringapiDocFileFolder()StringapiDocFilename(String templateName, String tag)Return the full path and API documentation fileMap<String,String>apiDocTemplateFiles()StringapiFileFolder()StringapiFilename(String templateName, String tag)StringapiPackage()Map<String,String>apiTemplateFiles()StringapiTestFileFolder()StringapiTestFilename(String templateName, String tag)Return the full path and API test fileMap<String,String>apiTestTemplateFiles()protected List<Map<String,Object>>buildEnumVars(List<Object> values, String dataType)protected CliOptionbuildLibraryCliOption(Map<String,String> supportedLibraries)List<CliOption>cliOptions()booleanconvertPropertyToBoolean(String propertyKey)booleanconvertPropertyToBooleanAndWriteBack(String propertyKey)reads propertyKey from additionalProperties, converts it to a boolean and writes it back to additionalProperties to be usable as a boolean in mustache files.protected CodegenDiscriminatorcreateDiscriminator(String schemaName, io.swagger.v3.oas.models.media.Schema schema)Set<String>defaultIncludes()StringdefaultTemplatingEngine()StringembeddedTemplateDir()StringencodePath(String input)StringescapeQuotationMark(String input)Escape single and/or double quote to avoid code injectionStringescapeReservedWord(String name)Return the escaped name of the reserved wordStringescapeText(String input)StringescapeTextWhileAllowingNewLines(String input)Escape characters while allowing new linesStringescapeUnsafeCharacters(String input)override with any special text escaping logic to handle unsafe characters so as to avoid code injectionStringfileSuffix()StringfindCommonPrefixOfVars(List<Object> vars)Returns the common prefix of variables for enum naming if two or more variables are presentprotected io.swagger.v3.oas.models.responses.ApiResponsefindMethodResponse(io.swagger.v3.oas.models.responses.ApiResponses responses)Override with any special handling of response codesCodegenCallbackfromCallback(String name, io.swagger.v3.oas.models.callbacks.Callback callback, List<io.swagger.v3.oas.models.servers.Server> servers)Convert OAS Callback object to Codegen Callback objectCodegenParameterfromFormProperty(String name, io.swagger.v3.oas.models.media.Schema propertySchema, Set<String> imports)CodegenModelfromModel(String name, io.swagger.v3.oas.models.media.Schema schema)Convert OAS Model object to Codegen Model object.CodegenOperationfromOperation(String path, String httpMethod, io.swagger.v3.oas.models.Operation operation, List<io.swagger.v3.oas.models.servers.Server> servers)Convert OAS Operation object to Codegen Operation objectCodegenParameterfromParameter(io.swagger.v3.oas.models.parameters.Parameter parameter, Set<String> imports)Convert OAS Parameter object to Codegen Parameter objectCodegenPropertyfromProperty(String name, io.swagger.v3.oas.models.media.Schema p)TODO remove this in 7.0.0 as a breaking change This method was kept when required was added to the fromProperty signature to ensure that the change was non-breakingCodegenPropertyfromProperty(String name, io.swagger.v3.oas.models.media.Schema p, boolean required)TODO remove this in 7.0.0 as a breaking change This method was kept when required was added to the fromProperty signature to ensure that the change was non-breakingCodegenPropertyfromProperty(String name, io.swagger.v3.oas.models.media.Schema p, boolean required, boolean schemaIsFromAdditionalProperties)Convert OAS Property object to Codegen Property object.CodegenParameterfromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody body, Set<String> imports, String bodyParameterName)List<CodegenParameter>fromRequestBodyToFormParameters(io.swagger.v3.oas.models.parameters.RequestBody body, Set<String> imports)CodegenResponsefromResponse(String responseCode, io.swagger.v3.oas.models.responses.ApiResponse response)Convert OAS Response object to Codegen Response objectList<CodegenSecurity>fromSecurity(Map<String,io.swagger.v3.oas.models.security.SecurityScheme> securitySchemeMap)Convert map of OAS SecurityScheme objects to a list of Codegen Security objectsList<CodegenServer>fromServers(List<io.swagger.v3.oas.models.servers.Server> servers)List<CodegenServerVariable>fromServerVariables(Map<String,io.swagger.v3.oas.models.servers.ServerVariable> variables)StringgenerateExamplePath(String path, io.swagger.v3.oas.models.Operation operation)Return the example pathprotected voidgenerateJSONSpecFile(Map<String,Object> objs)generates OpenAPI specification file in JSON formatvoidgenerateYAMLSpecFile(Map<String,Object> objs)generates OpenAPI specification file in YAML formatGeneratorLanguagegeneratorLanguage()StringgeneratorLanguageVersion()protected StringgetAdditionalPropertiesName()booleangetAddSuffixToDuplicateOperationNicknames()StringgetAlias(String name)Determine the type alias for the given type if it exists.Map<String,CodegenModel>getAllModels(Map<String,ModelsMap> objs)Index all CodegenModels by model name.protected List<CodegenDiscriminator.MappedModel>getAllOfDescendants(String thisSchemaName)BooleangetAllowUnicodeIdentifiers()StringgetApiNamePrefix()StringgetApiNameSuffix()protected StringgetCollectionFormat(io.swagger.v3.oas.models.parameters.Parameter parameter)protected StringgetCollectionFormat(CodegenParameter codegenParameter)Builds OAPI 2.0 collectionFormat value based on style and explode values for theCodegenParameter.static Set<String>getConsumesInfo(io.swagger.v3.oas.models.OpenAPI openAPI, io.swagger.v3.oas.models.Operation operation)protected LinkedHashMap<String,CodegenMediaType>getContent(io.swagger.v3.oas.models.media.Content content, Set<String> imports, String mediaTypeSchemaSuffix)protected StringgetContentType(io.swagger.v3.oas.models.parameters.RequestBody requestBody)BooleangetDisallowAdditionalPropertiesIfNotPresent()StringgetDocExtension()Documentation files extensionBooleangetEnsureUniqueParams()protected StringgetEnumDefaultValue(String defaultValue, String dataType)BooleangetEnumUnknownDefaultCase()FeatureSetgetFeatureSet()StringgetFilesMetadataFilename()GeneratorMetadatagetGeneratorMetadata()Returns metadata about the generator.StringgetGitHost()Git host.StringgetGitRepoId()Git repo IDStringgetGitUserId()Git user IDStringgetHelp()StringgetHttpUserAgent()HTTP user agentStringgetIgnoreFilePathOverride()Provides an override location, if any is specified, for the .openapi-generator-ignore.protected Map<String,Object>getInnerEnumAllowableValues(CodegenProperty property)StringgetInputSpec()protected StringgetItemsName(io.swagger.v3.oas.models.media.Schema containingSchema, String containingSchemaName)BooleangetLegacyDiscriminatorBehavior()StringgetLibrary()Library template (sub-template).StringgetModelNamePrefix()StringgetModelNameSuffix()protected Map<String,io.swagger.v3.oas.models.media.Schema>getModelNameToSchemaCache()Return a map from model name to Schema for efficient lookup.protected CodegenPropertygetMostInnerItems(CodegenProperty property)StringgetName()protected List<CodegenDiscriminator.MappedModel>getOneOfAnyOfDescendants(String composedSchemaName, String discPropName, io.swagger.v3.oas.models.media.ComposedSchema c)This function is only used for composed schemas which have a discriminator Process oneOf and anyOf models in a composed schema and adds them into a list if the oneOf and anyOf models contain the required discriminator.protected StringgetOrGenerateOperationId(io.swagger.v3.oas.models.Operation operation, String path, String httpMethod)Get operationId from the operation object, and if it's blank, generate a new one from the given parameters.StringgetOutputDir()protected StringgetParameterDataType(io.swagger.v3.oas.models.parameters.Parameter parameter, io.swagger.v3.oas.models.media.Schema schema)Returns the data type of parameter.BooleangetPrependFormOrBodyParameters()static Set<String>getProducesInfo(io.swagger.v3.oas.models.OpenAPI openAPI, io.swagger.v3.oas.models.Operation operation)returns the list of MIME types the APIs can produceStringgetReleaseNote()Release noteintgetRemoveOperationIdPrefixCount()StringgetRemoveOperationIdPrefixDelimiter()protected io.swagger.v3.oas.models.media.Schema<?>getSchemaAdditionalProperties(io.swagger.v3.oas.models.media.Schema schema)protected io.swagger.v3.oas.models.media.SchemagetSchemaFromBooleanOrSchema(Object schema)Used to ensure that null or Schema is returned given an input Boolean/Schema/null This will be used in openapi 3.1.0 spec processing to ensure that Booleans become Schemas Because our generators only understand Schemas Note: use getIsBooleanSchemaTrue or getIsBooleanSchemaFalse on the IJsonSchemaValidationProperties if you need to be able to detect if the original schema's value was true or falseprotected io.swagger.v3.oas.models.media.Schema<?>getSchemaItems(io.swagger.v3.oas.models.media.ArraySchema schema)StringgetSchemaType(io.swagger.v3.oas.models.media.Schema schema)returns the OpenAPI type for the property.protected StringgetSingleSchemaType(io.swagger.v3.oas.models.media.Schema schema)Return a string representation of the schema type, resolving aliasing and references if necessary.BooleangetSortModelPropertiesByRequiredFlag()BooleangetSortParamsByRequiredFlag()List<VendorExtension>getSupportedVendorExtensions()protected StringgetSymbolName(String input)Return the symbol name of a symbolCodegenTypegetTag()TemplatingEngineAdaptergetTemplatingEngine()StringgetterAndSetterCapitalize(String name)Camelize the method name of the getter and setterStringgetTypeDeclaration(io.swagger.v3.oas.models.media.Schema schema)Output the language-specific type declaration of the property.StringgetTypeDeclaration(String name)Output the language-specific type declaration of a given OAS name.booleangetUseInlineModelResolver()BooleangetUseOneOfInterfaces()booleangetUseOpenAPINormalizer()StringgetVersionMetadataFilename()protected voidhandleMethodResponse(io.swagger.v3.oas.models.Operation operation, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, CodegenOperation op, io.swagger.v3.oas.models.responses.ApiResponse methodResponse)Set op's returnBaseType, returnType, examples etc.protected voidhandleMethodResponse(io.swagger.v3.oas.models.Operation operation, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, CodegenOperation op, io.swagger.v3.oas.models.responses.ApiResponse methodResponse, Map<String,String> schemaMappings)Set op's returnBaseType, returnType, examples etc.protected StringhandleSpecialCharacters(String name)booleanhasBodyParameter(io.swagger.v3.oas.models.Operation operation)booleanhasFormParameter(io.swagger.v3.oas.models.Operation operation)Map<String,String>importMapping()protected voidinitializeSpecialCharacterMapping()Initialize special character mappingMap<String,String>inlineSchemaNameMapping()Map<String,String>inlineSchemaOption()Map<String,String>instantiationTypes()booleanisAnyTypeSchema(io.swagger.v3.oas.models.media.Schema schema)This method has been kept to keep the introduction of ModelUtils.isAnyType as a non-breaking change this way, existing forks of our generator can continue to use this method TODO in 6.0.0 replace this method with ModelUtils.isAnyType Return true if the schema value can be any type, i.e.booleanisDataTypeBinary(String dataType)booleanisDataTypeFile(String dataType)booleanisDataTypeString(String dataType)checks if the data should be classified as "string" in enum e.g.booleanisEnableMinimalUpdate()Get the boolean value indicating the state of the option for updating only changed filesbooleanisEnablePostProcessFile()Boolean value indicating the state of the option for post-processing file using environment variables.booleanisHideGenerationTimestamp()static booleanisJsonMimeType(String mime)Check if the given MIME is a JSON MIME.protected static booleanisJsonVendorMimeType(String mime)Check if the given MIME is a JSON Vendor MIME.booleanisLibrary(String library)check if current active library equals to passedbooleanisParameterNameUnique(CodegenParameter p, List<CodegenParameter> parameters)protected BooleanisPropertyInnerMostEnum(CodegenProperty property)Update property for map containerbooleanisRemoveEnumValuePrefix()Get the boolean value indicating whether to remove enum value prefixesbooleanisRemoveOperationIdPrefix()protected booleanisReservedWord(String word)booleanisSkipOperationExample()booleanisSkipOverwrite()booleanisStrictSpecBehavior()Indicates whether the codegen configuration should treat documents as strictly defined by the OpenAPI specification.static booleanisXmlMimeType(String mime)Set<String>languageSpecificPrimitives()StringlowerCamelCase(String name)Return the lowerCamelCase of the stringStringmodelDocFileFolder()Map<String,String>modelDocTemplateFiles()StringmodelFileFolder()StringmodelFilename(String templateName, String modelName)Map<String,String>modelNameMapping()StringmodelPackage()Map<String,String>modelTemplateFiles()StringmodelTestFileFolder()Map<String,String>modelTestTemplateFiles()protected voidmodifyFeatureSet(Consumer<FeatureSet.Builder> processor)Map<String,String>nameMapping()protected booleanneedToImport(String type)Check the type to see if it needs import the library/module/packageMap<String,String>openapiNormalizer()StringoutputFolder()Map<String,String>parameterNameMapping()voidpostProcess()Map<String,ModelsMap>postProcessAllModels(Map<String,ModelsMap> objs)voidpostProcessFile(File file, String fileType)Post-process the auto-generated file, e.g.voidpostProcessModelProperty(CodegenModel model, CodegenProperty property)ModelsMappostProcessModels(ModelsMap objs)ModelsMappostProcessModelsEnum(ModelsMap objs)post process enum defined in model's propertiesOperationsMappostProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)voidpostProcessParameter(CodegenParameter parameter)Map<String,Object>postProcessSupportingFileData(Map<String,Object> objs)voidpreprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)com.samskivert.mustache.Mustache.CompilerprocessCompiler(com.samskivert.mustache.Mustache.Compiler compiler)voidprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)voidprocessOpts()TemplatingEngineAdapterprocessTemplatingEngine(TemplatingEngineAdapter templatingEngine)protected ObjectprocessTestExampleData(Object data)A method that allows generators to pre-process test example payloads This can be useful if one needs to change how values like null in string are representedprotected voidremoveImport(OperationsMap objs, String importToRemove)Removes importToRemove from the imports of objs, if present.StringremoveNonNameElementToCamelCase(String name)Remove characters not suitable for variable or method name from the input and camelize itprotected StringremoveNonNameElementToCamelCase(String name, String nonNameElementPattern)Remove characters that is not good to be included in method name from the input and camelize itprotected voidremoveOption(String key)protected voidremoveSelfReferenceImports(CodegenModel model)Removes imports from the model that points to itself Marks a self referencing property, if detectedSet<String>reservedWords()Map<String,String>reservedWordsMappings()StringsanitizeName(String name)Sanitize name (parameter, property, method, etc)StringsanitizeName(String name, String removeCharRegEx)Sanitize name (parameter, property, method, etc)StringsanitizeName(String name, String removeCharRegEx, ArrayList<String> exceptionList)Sanitize name (parameter, property, method, etc)StringsanitizeTag(String tag)Sanitize tagMap<String,String>schemaMapping()Map<String,String>serverVariableOverrides()protected voidsetAddProps(io.swagger.v3.oas.models.media.Schema schema, IJsonSchemaValidationProperties property)voidsetAllowUnicodeIdentifiers(Boolean allowUnicodeIdentifiers)voidsetApiNamePrefix(String apiNamePrefix)voidsetApiNameSuffix(String apiNameSuffix)voidsetApiPackage(String apiPackage)voidsetCircularReferences(Map<String,CodegenModel> models)voidsetDisallowAdditionalPropertiesIfNotPresent(boolean val)voidsetDocExtension(String userDocExtension)Set Documentation files extensionvoidsetEnableMinimalUpdate(boolean enableMinimalUpdate)Set the boolean value indicating the state of the option for updating only changed filesvoidsetEnablePostProcessFile(boolean enablePostProcessFile)Set the boolean value indicating the state of the option for post-processing file using environment variables.voidsetEnsureUniqueParams(Boolean ensureUniqueParams)voidsetEnumUnknownDefaultCase(boolean val)voidsetFilesMetadataFilename(String filesMetadataFilename)voidsetGitHost(String gitHost)Set Git host.voidsetGitRepoId(String gitRepoId)Set Git repo ID.voidsetGitUserId(String gitUserId)Set Git user ID.voidsetHideGenerationTimestamp(boolean hideGenerationTimestamp)voidsetHttpUserAgent(String httpUserAgent)Set HTTP user agent.voidsetIgnoreFilePathOverride(String ignoreFileOverride)Sets an override location for the '.openapi-generator-ignore' location for the first code generation.voidsetInputSpec(String inputSpec)voidsetLegacyDiscriminatorBehavior(boolean val)voidsetLibrary(String library)Set library template (sub-template).voidsetModelNamePrefix(String modelNamePrefix)voidsetModelNameSuffix(String modelNameSuffix)voidsetModelPackage(String modelPackage)protected voidsetNonArrayMapProperty(CodegenProperty property, String type)voidsetOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)Set the OpenAPI document.voidsetOutputDir(String dir)voidsetParameterBooleanFlagWithCodegenProperty(CodegenParameter parameter, CodegenProperty property)Set CodegenParameter boolean flag using CodegenProperty.voidsetParameterEncodingValues(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.MediaType mediaType)Sets the content type, style, and explode of the parameter based on the encoding specified in the request body.voidsetParameterExamples(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)Return the examples of the parameter.voidsetParameterExampleValue(CodegenParameter codegenParameter)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.voidsetParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.RequestBody requestBody)Return the example value of the parameter.protected voidsetParameterNullable(CodegenParameter parameter, CodegenProperty property)voidsetPrependFormOrBodyParameters(Boolean prependFormOrBodyParameters)voidsetReleaseNote(String releaseNote)Set release note.voidsetRemoveEnumValuePrefix(boolean removeEnumValuePrefix)Set the boolean value indicating whether to remove enum value prefixesvoidsetRemoveOperationIdPrefix(boolean removeOperationIdPrefix)voidsetRemoveOperationIdPrefixCount(int removeOperationIdPrefixCount)voidsetRemoveOperationIdPrefixDelimiter(String removeOperationIdPrefixDelimiter)protected voidsetReservedWordsLowerCase(List<String> words)voidsetSkipOperationExample(boolean skipOperationExample)voidsetSkipOverwrite(boolean skipOverwrite)voidsetSortModelPropertiesByRequiredFlag(Boolean sortModelPropertiesByRequiredFlag)voidsetSortParamsByRequiredFlag(Boolean sortParamsByRequiredFlag)voidsetStrictSpecBehavior(boolean strictSpecBehavior)Sets the boolean valid indicating whether generation will work strictly against the specification, potentially making minor changes to the input document.voidsetTemplateDir(String templateDir)voidsetTemplatingEngine(TemplatingEngineAdapter templatingEngine)voidsetUseOneOfInterfaces(Boolean useOneOfInterfaces)voidsetVersionMetadataFilename(String versionMetadataFilename)protected booleanshouldAddImport(String type)booleanshouldOverwrite(String filename)Map<String,String>supportedLibraries()All library templates supported.List<SupportingFile>supportingFiles()StringtemplateDir()StringtestPackage()StringtoAllOfName(List<String> names, io.swagger.v3.oas.models.media.ComposedSchema composedSchema)Return the name of the 'allOf' composed schema.StringtoAnyOfName(List<String> names, io.swagger.v3.oas.models.media.ComposedSchema composedSchema)Return the name of the anyOf schemaStringtoApiDocFilename(String name)Return the file name of the Api DocumentationStringtoApiFilename(String name)Return the file name of the Api TestStringtoApiImport(String name)Return the fully-qualified "Api" name for importStringtoApiName(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 ApiStringtoArrayModelParamName(String name)Return the parameter name of array of modelStringtoBooleanGetter(String name)Output the Getter name for boolean property, e.g.StringtoDefaultParameterValue(io.swagger.v3.oas.models.media.Schema<?> schema)Return the default value of the parameterStringtoDefaultParameterValue(CodegenProperty codegenProperty, io.swagger.v3.oas.models.media.Schema<?> schema)Return the default value of the parameterStringtoDefaultValue(io.swagger.v3.oas.models.media.Schema schema)Return the default value of the propertyStringtoDefaultValue(CodegenProperty codegenProperty, io.swagger.v3.oas.models.media.Schema schema)Return the default value of the propertyStringtoDefaultValueWithParam(String name, io.swagger.v3.oas.models.media.Schema schema)Return the property initialized from a data object Useful for initialization with a plain object in JavascriptStringtoEnumDefaultValue(String value, String datatype)Return the enum default value in the language specified formatStringtoEnumName(CodegenProperty property)Return the Enum name (e.g.StringtoEnumValue(String value, String datatype)Return the enum value in the language specified format e.g.StringtoEnumVarName(String value, String datatype)Return the sanitized variable name for enumprotected List<Map<String,Object>>toExamples(Map<String,Object> examples)StringtoExampleValue(io.swagger.v3.oas.models.media.Schema schema)Return the example value of the propertyStringtoGetter(String name)Output the Getter name, e.g.StringtoInstantiationType(io.swagger.v3.oas.models.media.Schema schema)Return the instantiation type of the property, especially for map and arrayprotected StringtoMediaTypeSchemaName(String contentType, String mediaTypeSchemaSuffix)StringtoModelDocFilename(String name)Return the capitalized file name of the model documentationStringtoModelFilename(String name)Return the capitalized file name of the modelStringtoModelImport(String name)Return the fully-qualified "Model" name for importMap<String,String>toModelImportMap(String name)Returns the same content as [[toModelImport]] with key the fully-qualified Model name and value the initial input.StringtoModelName(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 testStringtoOneOfName(List<String> names, io.swagger.v3.oas.models.media.ComposedSchema composedSchema)Return the name of the oneOf schema.StringtoOperationId(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.StringtoRegularExpression(String pattern)Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)StringtoSetter(String name)Output the Setter name, e.g.protected StringtoTestCaseName(String specTestCaseName)StringtoVarName(String name)Return the variable name by removing invalid characters and proper escaping if it's a reserved word.Map<String,String>typeMapping()protected Map<String,io.swagger.v3.oas.models.media.Schema>unaliasPropertySchema(Map<String,io.swagger.v3.oas.models.media.Schema> properties)Loop through properties and unalias the reference if $ref (reference) is definedio.swagger.v3.oas.models.media.SchemaunaliasSchema(io.swagger.v3.oas.models.media.Schema schema)Map<String,ModelsMap>updateAllModels(Map<String,ModelsMap> objs)Loop through all models to update different flags (e.g.voidupdateCodegenPropertyEnum(CodegenProperty var)Update codegen property's enum by adding "enumVars" (with name and value)protected voidupdateDataTypeWithEnumForArray(CodegenProperty property)Update datatypeWithEnum for array containerprotected voidupdateDataTypeWithEnumForMap(CodegenProperty property)Update datatypeWithEnum for map containerprotected voidupdateEnumVarsWithExtensions(List<Map<String,Object>> enumVars, Map<String,Object> vendorExtensions, String dataType)protected voidupdateModelForAnyType(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema)protected voidupdateModelForComposedSchema(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema, Map<String,io.swagger.v3.oas.models.media.Schema> allDefinitions)protected voidupdateModelForInteger(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)protected voidupdateModelForNumber(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)protected voidupdateModelForObject(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema)protected voidupdateModelForString(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)Sets the booleans that define the model's typeprotected voidupdateOption(String key, String defaultValue)protected voidupdateParameterForString(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema parameterSchema)protected voidupdatePropertyForAnyType(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)protected voidupdatePropertyForArray(CodegenProperty property, CodegenProperty innerProperty)Update property for array(list) containerprotected voidupdatePropertyForInteger(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)protected voidupdatePropertyForMap(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)protected voidupdatePropertyForMap(CodegenProperty property, CodegenProperty innerProperty)Update property for map containerprotected voidupdatePropertyForNumber(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)protected voidupdatePropertyForObject(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)protected voidupdatePropertyForString(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)protected voidupdateRequestBodyForArray(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String name, Set<String> imports, String bodyParameterName)protected voidupdateRequestBodyForMap(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String name, Set<String> imports, String bodyParameterName)protected voidupdateRequestBodyForObject(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String name, Set<String> imports, String bodyParameterName)protected voidupdateRequestBodyForPrimitiveType(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String bodyParameterName, Set<String> imports)protected voidupdateRequestBodyForString(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, Set<String> imports, String bodyParameterName)Map<String,Object>vendorExtensions()voidwritePropertyBack(String propertyKey, Object value)
-
-
-
Field Detail
-
DefaultFeatureSet
public static FeatureSet DefaultFeatureSet
-
falseSchema
protected static io.swagger.v3.oas.models.media.Schema falseSchema
-
trueSchema
protected static io.swagger.v3.oas.models.media.Schema trueSchema
-
generatorMetadata
protected GeneratorMetadata generatorMetadata
-
inputSpec
protected String inputSpec
-
outputFolder
protected String outputFolder
-
modelPackage
protected String modelPackage
-
apiPackage
protected String apiPackage
-
fileSuffix
protected String fileSuffix
-
modelNamePrefix
protected String modelNamePrefix
-
modelNameSuffix
protected String modelNameSuffix
-
apiNamePrefix
protected String apiNamePrefix
-
apiNameSuffix
protected String apiNameSuffix
-
testPackage
protected String testPackage
-
filesMetadataFilename
protected String filesMetadataFilename
-
versionMetadataFilename
protected String versionMetadataFilename
-
templateDir
protected String templateDir
-
embeddedTemplateDir
protected String embeddedTemplateDir
-
supportingFiles
protected List<SupportingFile> supportingFiles
-
skipOverwrite
protected boolean skipOverwrite
-
removeOperationIdPrefix
protected boolean removeOperationIdPrefix
-
removeOperationIdPrefixDelimiter
protected String removeOperationIdPrefixDelimiter
-
removeOperationIdPrefixCount
protected int removeOperationIdPrefixCount
-
skipOperationExample
protected boolean skipOperationExample
-
XML_MIME_PATTERN
protected static final Pattern XML_MIME_PATTERN
-
JSON_MIME_PATTERN
protected static final Pattern JSON_MIME_PATTERN
-
JSON_VENDOR_MIME_PATTERN
protected static final Pattern JSON_VENDOR_MIME_PATTERN
-
supportsMultipleInheritance
protected boolean supportsMultipleInheritance
True if the code generator supports multiple class inheritance. This is used to model the parent hierarchy based on the 'allOf' composed schemas.
-
supportsInheritance
protected boolean supportsInheritance
True if the code generator supports single class inheritance. This is used to model the parent hierarchy based on the 'allOf' composed schemas. Note: the single-class inheritance technique has inherent limitations because a 'allOf' composed schema may have multiple $ref child schemas, each one potentially representing a "parent" in the class inheritance hierarchy. Some language generators also use class inheritance to implement the `additionalProperties` keyword. For example, the Java code generator may generate 'extends HashMap'.
-
supportsAdditionalPropertiesWithComposedSchema
protected boolean supportsAdditionalPropertiesWithComposedSchema
True if the language generator supports the 'additionalProperties' keyword as sibling of a composed (allOf/anyOf/oneOf) schema. Note: all language generators should support this to comply with the OAS specification.
-
supportsMixins
protected boolean supportsMixins
-
library
protected String library
-
sortParamsByRequiredFlag
protected Boolean sortParamsByRequiredFlag
-
sortModelPropertiesByRequiredFlag
protected Boolean sortModelPropertiesByRequiredFlag
-
ensureUniqueParams
protected Boolean ensureUniqueParams
-
allowUnicodeIdentifiers
protected Boolean allowUnicodeIdentifiers
-
gitHost
protected String gitHost
-
gitUserId
protected String gitUserId
-
gitRepoId
protected String gitRepoId
-
releaseNote
protected String releaseNote
-
httpUserAgent
protected String httpUserAgent
-
hideGenerationTimestamp
protected Boolean hideGenerationTimestamp
-
prependFormOrBodyParameters
protected Boolean prependFormOrBodyParameters
-
docExtension
protected String docExtension
-
ignoreFilePathOverride
protected String ignoreFilePathOverride
-
enablePostProcessFile
protected boolean enablePostProcessFile
-
useOneOfInterfaces
protected boolean useOneOfInterfaces
-
addOneOfInterfaceImports
protected boolean addOneOfInterfaceImports
-
addOneOfInterfaces
protected List<CodegenModel> addOneOfInterfaces
-
enableMinimalUpdate
protected boolean enableMinimalUpdate
-
strictSpecBehavior
protected boolean strictSpecBehavior
-
removeEnumValuePrefix
protected boolean removeEnumValuePrefix
-
legacyDiscriminatorBehavior
protected boolean legacyDiscriminatorBehavior
-
disallowAdditionalPropertiesIfNotPresent
protected boolean disallowAdditionalPropertiesIfNotPresent
-
enumUnknownDefaultCase
protected boolean enumUnknownDefaultCase
-
enumUnknownDefaultCaseName
protected String enumUnknownDefaultCaseName
-
openAPI
protected io.swagger.v3.oas.models.OpenAPI openAPI
-
loadDeepObjectIntoItems
protected boolean loadDeepObjectIntoItems
-
importBaseType
protected boolean importBaseType
-
importContainerType
protected boolean importContainerType
-
addSuffixToDuplicateOperationNicknames
protected boolean addSuffixToDuplicateOperationNicknames
-
-
Constructor Detail
-
DefaultCodegen
public DefaultCodegen()
Default constructor. This method will map between OAS type and language-specified type, as well as mapping between OAS type and the corresponding import statement for the language. This will also add some language specified CLI options, if any. returns string presentation of the example path (it's a constructor)
-
-
Method Detail
-
getAddSuffixToDuplicateOperationNicknames
public boolean getAddSuffixToDuplicateOperationNicknames()
- Specified by:
getAddSuffixToDuplicateOperationNicknamesin interfaceCodegenConfig
-
cliOptions
public List<CliOption> cliOptions()
- Specified by:
cliOptionsin interfaceCodegenConfig
-
processOpts
public void processOpts()
- Specified by:
processOptsin interfaceCodegenConfig
-
addMustacheLambdas
protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda> addMustacheLambdas()
Preset 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.- Returns:
- preinitialized map with common lambdas
-
postProcessAllModels
public Map<String,ModelsMap> postProcessAllModels(Map<String,ModelsMap> objs)
- Specified by:
postProcessAllModelsin interfaceCodegenConfig
-
getModelNameToSchemaCache
protected Map<String,io.swagger.v3.oas.models.media.Schema> getModelNameToSchemaCache()
Return a map from model name to Schema for efficient lookup.- Returns:
- map from model name to Schema.
-
getAllModels
public Map<String,CodegenModel> getAllModels(Map<String,ModelsMap> objs)
Index all CodegenModels by model name.- Parameters:
objs- Map of models- Returns:
- map of all models indexed by names
-
updateAllModels
public Map<String,ModelsMap> updateAllModels(Map<String,ModelsMap> objs)
Loop through all models to update different flags (e.g. isSelfReference), children models, etc and update mapped models for import.- Specified by:
updateAllModelsin interfaceCodegenConfig- Parameters:
objs- Map of models- Returns:
- maps of models with various updates
-
removeImport
protected void removeImport(OperationsMap objs, String importToRemove)
Removes importToRemove from the imports of objs, if present. This is useful to remove imports that are already present in operations-related template files, to avoid importing the same thing twice.- Parameters:
objs- imports will be removed from this objs' imports collectionimportToRemove- the import statement to be removed
-
removeSelfReferenceImports
protected void removeSelfReferenceImports(CodegenModel model)
Removes imports from the model that points to itself Marks a self referencing property, if detected- Parameters:
model- Self imports will be removed from this model.imports collection
-
setCircularReferences
public void setCircularReferences(Map<String,CodegenModel> models)
-
postProcessModels
public ModelsMap postProcessModels(ModelsMap objs)
- Specified by:
postProcessModelsin interfaceCodegenConfig
-
postProcessModelsEnum
public ModelsMap postProcessModelsEnum(ModelsMap objs)
post process enum defined in model's properties- Parameters:
objs- Map of models- Returns:
- maps of models with better enum support
-
findCommonPrefixOfVars
public String findCommonPrefixOfVars(List<Object> vars)
Returns the common prefix of variables for enum naming if two or more variables are present- Parameters:
vars- List of variable names- Returns:
- the common prefix for naming
-
toEnumDefaultValue
public String toEnumDefaultValue(String value, String datatype)
Return the enum default value in the language specified format- Parameters:
value- enum variable namedatatype- data type- Returns:
- the default value for the enum
-
toEnumValue
public String toEnumValue(String value, String datatype)
Return the enum value in the language specified format e.g. status becomes "status"- Parameters:
value- enum variable namedatatype- data type- Returns:
- the sanitized value for enum
-
toEnumVarName
public String toEnumVarName(String value, String datatype)
Return the sanitized variable name for enum- Parameters:
value- enum variable namedatatype- data type- Returns:
- the sanitized variable name for enum
-
setOpenAPI
public void setOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
Set the OpenAPI document. This method is invoked when the input OpenAPI document has been parsed and validated.- Specified by:
setOpenAPIin interfaceCodegenConfig- Parameters:
openAPI- specification being generated
-
postProcess
public void postProcess()
- Specified by:
postProcessin interfaceCodegenConfig
-
postProcessOperationsWithModels
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)
- Specified by:
postProcessOperationsWithModelsin interfaceCodegenConfig
-
postProcessSupportingFileData
public Map<String,Object> postProcessSupportingFileData(Map<String,Object> objs)
- Specified by:
postProcessSupportingFileDatain interfaceCodegenConfig
-
postProcessModelProperty
public void postProcessModelProperty(CodegenModel model, CodegenProperty property)
- Specified by:
postProcessModelPropertyin interfaceCodegenConfig
-
postProcessParameter
public void postProcessParameter(CodegenParameter parameter)
- Specified by:
postProcessParameterin interfaceCodegenConfig
-
preprocessOpenAPI
public void preprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
- Specified by:
preprocessOpenAPIin interfaceCodegenConfig
-
processOpenAPI
public void processOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
- Specified by:
processOpenAPIin interfaceCodegenConfig
-
processCompiler
public com.samskivert.mustache.Mustache.Compiler processCompiler(com.samskivert.mustache.Mustache.Compiler compiler)
- Specified by:
processCompilerin interfaceCodegenConfig
-
processTemplatingEngine
public TemplatingEngineAdapter processTemplatingEngine(TemplatingEngineAdapter templatingEngine)
- Specified by:
processTemplatingEnginein interfaceCodegenConfig
-
escapeText
public String escapeText(String input)
- Specified by:
escapeTextin interfaceCodegenConfig
-
escapeTextWhileAllowingNewLines
public String escapeTextWhileAllowingNewLines(String input)
Escape characters while allowing new lines- Specified by:
escapeTextWhileAllowingNewLinesin interfaceCodegenConfig- Parameters:
input- String to be escaped- Returns:
- escaped string
-
encodePath
public String encodePath(String input)
- Specified by:
encodePathin interfaceCodegenConfig
-
escapeUnsafeCharacters
public String escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe characters so as to avoid code injection- Specified by:
escapeUnsafeCharactersin interfaceCodegenConfig- Parameters:
input- String to be cleaned up- Returns:
- string with unsafe characters removed or escaped
-
escapeQuotationMark
public String escapeQuotationMark(String input)
Escape single and/or double quote to avoid code injection- Specified by:
escapeQuotationMarkin interfaceCodegenConfig- Parameters:
input- String to be cleaned up- Returns:
- string with quotation mark removed or escaped
-
defaultIncludes
public Set<String> defaultIncludes()
- Specified by:
defaultIncludesin interfaceCodegenConfig
-
typeMapping
public Map<String,String> typeMapping()
- Specified by:
typeMappingin interfaceCodegenConfig
-
instantiationTypes
public Map<String,String> instantiationTypes()
- Specified by:
instantiationTypesin interfaceCodegenConfig
-
reservedWords
public Set<String> reservedWords()
- Specified by:
reservedWordsin interfaceCodegenConfig
-
languageSpecificPrimitives
public Set<String> languageSpecificPrimitives()
- Specified by:
languageSpecificPrimitivesin interfaceCodegenConfig
-
importMapping
public Map<String,String> importMapping()
- Specified by:
importMappingin interfaceCodegenConfig
-
schemaMapping
public Map<String,String> schemaMapping()
- Specified by:
schemaMappingin interfaceCodegenConfig
-
inlineSchemaNameMapping
public Map<String,String> inlineSchemaNameMapping()
- Specified by:
inlineSchemaNameMappingin interfaceCodegenConfig
-
inlineSchemaOption
public Map<String,String> inlineSchemaOption()
- Specified by:
inlineSchemaOptionin interfaceCodegenConfig
-
nameMapping
public Map<String,String> nameMapping()
- Specified by:
nameMappingin interfaceCodegenConfig
-
parameterNameMapping
public Map<String,String> parameterNameMapping()
- Specified by:
parameterNameMappingin interfaceCodegenConfig
-
modelNameMapping
public Map<String,String> modelNameMapping()
- Specified by:
modelNameMappingin interfaceCodegenConfig
-
openapiNormalizer
public Map<String,String> openapiNormalizer()
- Specified by:
openapiNormalizerin interfaceCodegenConfig
-
testPackage
public String testPackage()
- Specified by:
testPackagein interfaceCodegenConfig
-
modelPackage
public String modelPackage()
- Specified by:
modelPackagein interfaceCodegenConfig
-
apiPackage
public String apiPackage()
- Specified by:
apiPackagein interfaceCodegenConfig
-
fileSuffix
public String fileSuffix()
- Specified by:
fileSuffixin interfaceCodegenConfig
-
templateDir
public String templateDir()
- Specified by:
templateDirin interfaceCodegenConfig
-
embeddedTemplateDir
public String embeddedTemplateDir()
- Specified by:
embeddedTemplateDirin interfaceCodegenConfig
-
apiDocTemplateFiles
public Map<String,String> apiDocTemplateFiles()
- Specified by:
apiDocTemplateFilesin interfaceCodegenConfig
-
modelDocTemplateFiles
public Map<String,String> modelDocTemplateFiles()
- Specified by:
modelDocTemplateFilesin interfaceCodegenConfig
-
reservedWordsMappings
public Map<String,String> reservedWordsMappings()
- Specified by:
reservedWordsMappingsin interfaceCodegenConfig
-
apiTestTemplateFiles
public Map<String,String> apiTestTemplateFiles()
- Specified by:
apiTestTemplateFilesin interfaceCodegenConfig
-
modelTestTemplateFiles
public Map<String,String> modelTestTemplateFiles()
- Specified by:
modelTestTemplateFilesin interfaceCodegenConfig
-
apiTemplateFiles
public Map<String,String> apiTemplateFiles()
- Specified by:
apiTemplateFilesin interfaceCodegenConfig
-
modelTemplateFiles
public Map<String,String> modelTemplateFiles()
- Specified by:
modelTemplateFilesin interfaceCodegenConfig
-
apiFileFolder
public String apiFileFolder()
- Specified by:
apiFileFolderin interfaceCodegenConfig
-
modelFileFolder
public String modelFileFolder()
- Specified by:
modelFileFolderin interfaceCodegenConfig
-
apiTestFileFolder
public String apiTestFileFolder()
- Specified by:
apiTestFileFolderin interfaceCodegenConfig
-
modelTestFileFolder
public String modelTestFileFolder()
- Specified by:
modelTestFileFolderin interfaceCodegenConfig
-
apiDocFileFolder
public String apiDocFileFolder()
- Specified by:
apiDocFileFolderin interfaceCodegenConfig
-
modelDocFileFolder
public String modelDocFileFolder()
- Specified by:
modelDocFileFolderin interfaceCodegenConfig
-
additionalProperties
public Map<String,Object> additionalProperties()
- Specified by:
additionalPropertiesin interfaceCodegenConfig
-
serverVariableOverrides
public Map<String,String> serverVariableOverrides()
- Specified by:
serverVariableOverridesin interfaceCodegenConfig
-
vendorExtensions
public Map<String,Object> vendorExtensions()
- Specified by:
vendorExtensionsin interfaceCodegenConfig
-
supportingFiles
public List<SupportingFile> supportingFiles()
- Specified by:
supportingFilesin interfaceCodegenConfig
-
outputFolder
public String outputFolder()
- Specified by:
outputFolderin interfaceCodegenConfig
-
setOutputDir
public void setOutputDir(String dir)
- Specified by:
setOutputDirin interfaceCodegenConfig
-
getOutputDir
public String getOutputDir()
- Specified by:
getOutputDirin interfaceCodegenConfig
-
getInputSpec
public String getInputSpec()
- Specified by:
getInputSpecin interfaceCodegenConfig
-
setInputSpec
public void setInputSpec(String inputSpec)
- Specified by:
setInputSpecin interfaceCodegenConfig
-
getFilesMetadataFilename
public String getFilesMetadataFilename()
- Specified by:
getFilesMetadataFilenamein interfaceCodegenConfig
-
setFilesMetadataFilename
public void setFilesMetadataFilename(String filesMetadataFilename)
-
getVersionMetadataFilename
public String getVersionMetadataFilename()
- Specified by:
getVersionMetadataFilenamein interfaceCodegenConfig
-
setVersionMetadataFilename
public void setVersionMetadataFilename(String versionMetadataFilename)
-
setTemplateDir
public void setTemplateDir(String templateDir)
-
setModelPackage
public void setModelPackage(String modelPackage)
-
getModelNamePrefix
public String getModelNamePrefix()
-
setModelNamePrefix
public void setModelNamePrefix(String modelNamePrefix)
-
getModelNameSuffix
public String getModelNameSuffix()
-
setModelNameSuffix
public void setModelNameSuffix(String modelNameSuffix)
-
getApiNameSuffix
public String getApiNameSuffix()
-
setApiNameSuffix
public void setApiNameSuffix(String apiNameSuffix)
-
getApiNamePrefix
public String getApiNamePrefix()
-
setApiNamePrefix
public void setApiNamePrefix(String apiNamePrefix)
-
setApiPackage
public void setApiPackage(String apiPackage)
-
getSortParamsByRequiredFlag
public Boolean getSortParamsByRequiredFlag()
-
setSortParamsByRequiredFlag
public void setSortParamsByRequiredFlag(Boolean sortParamsByRequiredFlag)
-
getSortModelPropertiesByRequiredFlag
public Boolean getSortModelPropertiesByRequiredFlag()
-
setSortModelPropertiesByRequiredFlag
public void setSortModelPropertiesByRequiredFlag(Boolean sortModelPropertiesByRequiredFlag)
-
getPrependFormOrBodyParameters
public Boolean getPrependFormOrBodyParameters()
-
setPrependFormOrBodyParameters
public void setPrependFormOrBodyParameters(Boolean prependFormOrBodyParameters)
-
getEnsureUniqueParams
public Boolean getEnsureUniqueParams()
-
setEnsureUniqueParams
public void setEnsureUniqueParams(Boolean ensureUniqueParams)
-
getLegacyDiscriminatorBehavior
public Boolean getLegacyDiscriminatorBehavior()
-
setLegacyDiscriminatorBehavior
public void setLegacyDiscriminatorBehavior(boolean val)
-
getDisallowAdditionalPropertiesIfNotPresent
public Boolean getDisallowAdditionalPropertiesIfNotPresent()
-
setDisallowAdditionalPropertiesIfNotPresent
public void setDisallowAdditionalPropertiesIfNotPresent(boolean val)
-
getEnumUnknownDefaultCase
public Boolean getEnumUnknownDefaultCase()
-
setEnumUnknownDefaultCase
public void setEnumUnknownDefaultCase(boolean val)
-
getAllowUnicodeIdentifiers
public Boolean getAllowUnicodeIdentifiers()
-
setAllowUnicodeIdentifiers
public void setAllowUnicodeIdentifiers(Boolean allowUnicodeIdentifiers)
-
getUseOneOfInterfaces
public Boolean getUseOneOfInterfaces()
-
setUseOneOfInterfaces
public void setUseOneOfInterfaces(Boolean useOneOfInterfaces)
-
toRegularExpression
public String toRegularExpression(String pattern)
Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)- Parameters:
pattern- the pattern (regular expression)- Returns:
- properly-escaped pattern
-
toApiFilename
public String toApiFilename(String name)
Return the file name of the Api Test- Specified by:
toApiFilenamein interfaceCodegenConfig- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toApiDocFilename
public String toApiDocFilename(String name)
Return the file name of the Api Documentation- Specified by:
toApiDocFilenamein interfaceCodegenConfig- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toApiTestFilename
public String toApiTestFilename(String name)
Return the file name of the Api Test- Specified by:
toApiTestFilenamein interfaceCodegenConfig- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toApiVarName
public String toApiVarName(String name)
Return the variable name in the Api- Specified by:
toApiVarNamein interfaceCodegenConfig- Parameters:
name- the variable name of the Api- Returns:
- the snake-cased variable name
-
toModelFilename
public String toModelFilename(String name)
Return the capitalized file name of the model- Specified by:
toModelFilenamein interfaceCodegenConfig- Parameters:
name- the model name- Returns:
- the file name of the model
-
toModelTestFilename
public String toModelTestFilename(String name)
Return the capitalized file name of the model test- Specified by:
toModelTestFilenamein interfaceCodegenConfig- Parameters:
name- the model name- Returns:
- the file name of the model
-
toModelDocFilename
public String toModelDocFilename(String name)
Return the capitalized file name of the model documentation- Specified by:
toModelDocFilenamein interfaceCodegenConfig- Parameters:
name- the model name- Returns:
- the file name of the model
-
getGeneratorMetadata
public GeneratorMetadata getGeneratorMetadata()
Returns metadata about the generator.- Specified by:
getGeneratorMetadatain interfaceCodegenConfig- Returns:
- A provided
GeneratorMetadatainstance
-
toOperationId
public String toOperationId(String operationId)
Return the operation ID (method name)- Parameters:
operationId- operation ID- Returns:
- the sanitized method name
-
toVarName
public String toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if it's a reserved word.- Parameters:
name- the variable name- Returns:
- the sanitized variable name
-
toParamName
public String toParamName(String name)
Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.- Specified by:
toParamNamein interfaceCodegenConfig- Parameters:
name- Codegen property object- Returns:
- the sanitized parameter name
-
toArrayModelParamName
public String toArrayModelParamName(String name)
Return the parameter name of array of model- Parameters:
name- name of the array model- Returns:
- the sanitized parameter name
-
toEnumName
public String toEnumName(CodegenProperty property)
Return the Enum name (e.g. StatusEnum given 'status')- Parameters:
property- Codegen property- Returns:
- the Enum name
-
escapeReservedWord
public String escapeReservedWord(String name)
Return the escaped name of the reserved word- Specified by:
escapeReservedWordin interfaceCodegenConfig- Parameters:
name- the name to be escaped- Returns:
- the escaped reserved word
throws Runtime exception as reserved word is not allowed (default behavior)
-
toModelImport
public String toModelImport(String name)
Return the fully-qualified "Model" name for import- Specified by:
toModelImportin interfaceCodegenConfig- Parameters:
name- the name of the "Model"- Returns:
- the fully-qualified "Model" name for import
-
toModelImportMap
public Map<String,String> toModelImportMap(String name)
Returns the same content as [[toModelImport]] with key the fully-qualified Model name and value the initial input. In case of union types this method has a key for each separate model and import.- Specified by:
toModelImportMapin interfaceCodegenConfig- Parameters:
name- the name of the "Model"- Returns:
- Map of fully-qualified models.
-
toApiImport
public String toApiImport(String name)
Return the fully-qualified "Api" name for import- Specified by:
toApiImportin interfaceCodegenConfig- Parameters:
name- the name of the "Api"- Returns:
- the fully-qualified "Api" name for import
-
initializeSpecialCharacterMapping
protected void initializeSpecialCharacterMapping()
Initialize special character mapping
-
getSymbolName
protected String getSymbolName(String input)
Return the symbol name of a symbol- Parameters:
input- Symbol (e.g. $)- Returns:
- Symbol name (e.g. Dollar)
-
generateExamplePath
public String generateExamplePath(String path, io.swagger.v3.oas.models.Operation operation)
Return the example path- Specified by:
generateExamplePathin interfaceCodegenConfig- Parameters:
path- the path of the operationoperation- OAS operation object- Returns:
- string presentation of the example path
-
toInstantiationType
public String toInstantiationType(io.swagger.v3.oas.models.media.Schema schema)
Return the instantiation type of the property, especially for map and array- Parameters:
schema- property schema- Returns:
- string presentation of the instantiation type of the property
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter codegenParameter)
Return the example value of the parameter.- Parameters:
codegenParameter- Codegen parameter
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)
Return the example value of the parameter.- Parameters:
codegenParameter- Codegen parameterparameter- Parameter
-
setParameterExamples
public void setParameterExamples(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)
Return the examples of the parameter.- Parameters:
codegenParameter- Codegen parameterparameter- Parameter
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.RequestBody requestBody)
Return the example value of the parameter.- Parameters:
codegenParameter- Codegen parameterrequestBody- Request body
-
setParameterEncodingValues
public void setParameterEncodingValues(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.MediaType mediaType)
Sets the content type, style, and explode of the parameter based on the encoding specified in the request body.- Parameters:
codegenParameter- Codegen parametermediaType- MediaType from the request body
-
toExampleValue
public String toExampleValue(io.swagger.v3.oas.models.media.Schema schema)
Return the example value of the propertyThis method should be overridden in the generator to meet its requirement.
- Parameters:
schema- Property schema- Returns:
- string presentation of the example value of the property
-
toDefaultValue
public String toDefaultValue(io.swagger.v3.oas.models.media.Schema schema)
Return the default value of the propertyThis method should be overridden in the generator to meet its requirement. Return null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Parameters:
schema- Property schema- Returns:
- string presentation of the default value of the property
-
toDefaultParameterValue
public String toDefaultParameterValue(io.swagger.v3.oas.models.media.Schema<?> schema)
Return the default value of the parameterReturn null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Parameters:
schema- Parameter schema- Returns:
- string presentation of the default value of the parameter
-
toDefaultParameterValue
public String toDefaultParameterValue(CodegenProperty codegenProperty, io.swagger.v3.oas.models.media.Schema<?> schema)
Return the default value of the parameterReturn null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Parameters:
codegenProperty- Codegen Propertyschema- Parameter schema- Returns:
- string presentation of the default value of the parameter
-
toDefaultValueWithParam
public String toDefaultValueWithParam(String name, io.swagger.v3.oas.models.media.Schema schema)
Return the property initialized from a data object Useful for initialization with a plain object in Javascript- Parameters:
name- Name of the property objectschema- Property schema- Returns:
- string presentation of the default value of the property
-
toDefaultValue
public String toDefaultValue(CodegenProperty codegenProperty, io.swagger.v3.oas.models.media.Schema schema)
Return the default value of the propertyReturn null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Parameters:
schema- Property schemacodegenProperty- Codegen property- Returns:
- string presentation of the default value of the property
-
getSchemaType
public String getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
returns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type- Parameters:
schema- property schema- Returns:
- string presentation of the type
-
getSchemaItems
protected io.swagger.v3.oas.models.media.Schema<?> getSchemaItems(io.swagger.v3.oas.models.media.ArraySchema schema)
-
getSchemaAdditionalProperties
protected io.swagger.v3.oas.models.media.Schema<?> getSchemaAdditionalProperties(io.swagger.v3.oas.models.media.Schema schema)
-
toAllOfName
public String toAllOfName(List<String> names, io.swagger.v3.oas.models.media.ComposedSchema composedSchema)
Return the name of the 'allOf' composed schema.- Parameters:
names- List of namescomposedSchema- composed schema- Returns:
- name of the allOf schema
-
toAnyOfName
public String toAnyOfName(List<String> names, io.swagger.v3.oas.models.media.ComposedSchema composedSchema)
Return the name of the anyOf schema- Parameters:
names- List of namescomposedSchema- composed schema- Returns:
- name of the anyOf schema
-
toOneOfName
public String toOneOfName(List<String> names, io.swagger.v3.oas.models.media.ComposedSchema composedSchema)
Return the name of the oneOf schema.This name is used to set the value of CodegenProperty.openApiType.
If the 'x-one-of-name' extension is specified in the OAS document, return that value. Otherwise, a name is constructed by creating a comma-separated list of all the names of the oneOf schemas.
- Parameters:
names- List of namescomposedSchema- composed schema- Returns:
- name of the oneOf schema
-
unaliasSchema
public io.swagger.v3.oas.models.media.Schema unaliasSchema(io.swagger.v3.oas.models.media.Schema schema)
- Specified by:
unaliasSchemain interfaceCodegenConfig
-
getSingleSchemaType
protected String getSingleSchemaType(io.swagger.v3.oas.models.media.Schema schema)
Return a string representation of the schema type, resolving aliasing and references if necessary.- Parameters:
schema- input- Returns:
- the string representation of the schema type.
-
lowerCamelCase
public String lowerCamelCase(String name)
Return the lowerCamelCase of the string- Parameters:
name- string to be lowerCamelCased- Returns:
- lowerCamelCase string
-
getTypeDeclaration
public String getTypeDeclaration(String name)
Output the language-specific type declaration of a given OAS name.- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Parameters:
name- name- Returns:
- a string presentation of the type
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema schema)
Output the language-specific type declaration of the property.- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Parameters:
schema- property schema- Returns:
- a string presentation of the property type
-
getAlias
public String getAlias(String name)
Determine the type alias for the given type if it exists. This feature was originally developed for Java because the language does not have an aliasing mechanism of its own but later extends to handle other languages- Parameters:
name- The type name.- Returns:
- The alias of the given type, if it exists. If there is no alias for this type, then returns the input type name.
-
toBooleanGetter
public String toBooleanGetter(String name)
Output the Getter name for boolean property, e.g. getActive- Specified by:
toBooleanGetterin interfaceCodegenConfig- Parameters:
name- the name of the property- Returns:
- getter name based on naming convention
-
toGetter
public String toGetter(String name)
Output the Getter name, e.g. getSize- Specified by:
toGetterin interfaceCodegenConfig- Parameters:
name- the name of the property- Returns:
- getter name based on naming convention
-
toSetter
public String toSetter(String name)
Output the Setter name, e.g. setSize- Specified by:
toSetterin interfaceCodegenConfig- Parameters:
name- the name of the property- Returns:
- setter name based on naming convention
-
toApiName
public String toApiName(String name)
Output the API (class) name (capitalized) ending with the specified or default suffix Return DefaultApi if name is empty- Specified by:
toApiNamein interfaceCodegenConfig- Parameters:
name- the name of the Api- Returns:
- capitalized Api name
-
toModelName
public String toModelName(String name)
Converts 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- Parameters:
name- the name of the model- Returns:
- capitalized model name
-
updateModelForComposedSchema
protected void updateModelForComposedSchema(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema, Map<String,io.swagger.v3.oas.models.media.Schema> allDefinitions)
-
updateModelForObject
protected void updateModelForObject(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema)
-
updateModelForAnyType
protected void updateModelForAnyType(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema)
-
processTestExampleData
protected Object processTestExampleData(Object data)
A method that allows generators to pre-process test example payloads This can be useful if one needs to change how values like null in string are represented- Parameters:
data- the test data payload- Returns:
- the updated test data payload
-
updateModelForString
protected void updateModelForString(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)
Sets the booleans that define the model's type- Parameters:
model- the model to updateschema- the model's schema
-
updateModelForNumber
protected void updateModelForNumber(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)
-
updateModelForInteger
protected void updateModelForInteger(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)
-
fromModel
public CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema schema)
Convert OAS Model object to Codegen Model object.- Specified by:
fromModelin interfaceCodegenConfig- Parameters:
name- the name of the modelschema- OAS Model object- Returns:
- Codegen Model object
-
setAddProps
protected void setAddProps(io.swagger.v3.oas.models.media.Schema schema, IJsonSchemaValidationProperties property)
-
getOneOfAnyOfDescendants
protected List<CodegenDiscriminator.MappedModel> getOneOfAnyOfDescendants(String composedSchemaName, String discPropName, io.swagger.v3.oas.models.media.ComposedSchema c)
This function is only used for composed schemas which have a discriminator Process oneOf and anyOf models in a composed schema and adds them into a list if the oneOf and anyOf models contain the required discriminator. If they don't contain the required discriminator or the discriminator is the wrong type then an error is thrown- Parameters:
composedSchemaName- The String model name of the composed schema where we are setting the discriminator mapdiscPropName- The String that is the discriminator propertyName in the schemac- The ComposedSchema that contains the discriminator and oneOf/anyOf schemas- Returns:
- the list of oneOf and anyOf MappedModel that need to be added to the discriminator map
-
getAllOfDescendants
protected List<CodegenDiscriminator.MappedModel> getAllOfDescendants(String thisSchemaName)
-
createDiscriminator
protected CodegenDiscriminator createDiscriminator(String schemaName, io.swagger.v3.oas.models.media.Schema schema)
-
addAdditionPropertiesToCodeGenModel
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)
Handle the model for the 'additionalProperties' keyword in the OAS schema.- Parameters:
codegenModel- The codegen representation of the schema.schema- The input OAS schema.
-
addProperties
protected void addProperties(Map<String,io.swagger.v3.oas.models.media.Schema> properties, List<String> required, io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
Add schema's properties to "properties" and "required" list- Parameters:
properties- all propertiesrequired- required property onlyschema- schema in which the properties will be added to the listsvisitedSchemas- circuit-breaker - the schemas with which the method was called before for recursive structures
-
getterAndSetterCapitalize
public String getterAndSetterCapitalize(String name)
Camelize the method name of the getter and setter- Parameters:
name- string to be camelized- Returns:
- Camelized string
-
updatePropertyForMap
protected void updatePropertyForMap(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)
-
updatePropertyForObject
protected void updatePropertyForObject(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)
-
updatePropertyForAnyType
protected void updatePropertyForAnyType(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)
-
updatePropertyForString
protected void updatePropertyForString(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)
-
updatePropertyForNumber
protected void updatePropertyForNumber(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)
-
updatePropertyForInteger
protected void updatePropertyForInteger(CodegenProperty property, io.swagger.v3.oas.models.media.Schema p)
-
fromProperty
public CodegenProperty fromProperty(String name, io.swagger.v3.oas.models.media.Schema p, boolean required)
TODO remove this in 7.0.0 as a breaking change This method was kept when required was added to the fromProperty signature to ensure that the change was non-breaking- Parameters:
name- name of the propertyp- OAS property schemarequired- true if the property is required in the next higher object schema, false otherwise- Returns:
- Codegen Property object
-
fromProperty
public CodegenProperty fromProperty(String name, io.swagger.v3.oas.models.media.Schema p)
TODO remove this in 7.0.0 as a breaking change This method was kept when required was added to the fromProperty signature to ensure that the change was non-breaking- Parameters:
name- name of the propertyp- OAS property schema- Returns:
- Codegen Property object
-
fromProperty
public CodegenProperty fromProperty(String name, io.swagger.v3.oas.models.media.Schema p, boolean required, boolean schemaIsFromAdditionalProperties)
Convert OAS Property object to Codegen Property object.The return value is cached. An internal cache is looked up to determine if the CodegenProperty return value has already been instantiated for the (String name, Schema p) arguments. Any subsequent processing of the CodegenModel return value must be idempotent for a given (String name, Schema schema).
- Parameters:
name- name of the propertyp- OAS property schemarequired- true if the property is required in the next higher object schema, false otherwiseschemaIsFromAdditionalProperties- true if the property is a required property defined by additional properties schema If this is the actual additionalProperties schema not defining a required property, then the value should be false- Returns:
- Codegen Property object
-
updatePropertyForArray
protected void updatePropertyForArray(CodegenProperty property, CodegenProperty innerProperty)
Update property for array(list) container- Parameters:
property- Codegen propertyinnerProperty- Codegen inner property of map or list
-
updatePropertyForMap
protected void updatePropertyForMap(CodegenProperty property, CodegenProperty innerProperty)
Update property for map container- Parameters:
property- Codegen propertyinnerProperty- Codegen inner property of map or list
-
isPropertyInnerMostEnum
protected Boolean isPropertyInnerMostEnum(CodegenProperty property)
Update property for map container- Parameters:
property- Codegen property- Returns:
- True if the inner most type is enum
-
getMostInnerItems
protected CodegenProperty getMostInnerItems(CodegenProperty property)
-
getInnerEnumAllowableValues
protected Map<String,Object> getInnerEnumAllowableValues(CodegenProperty property)
-
updateDataTypeWithEnumForArray
protected void updateDataTypeWithEnumForArray(CodegenProperty property)
Update datatypeWithEnum for array container- Parameters:
property- Codegen property
-
updateDataTypeWithEnumForMap
protected void updateDataTypeWithEnumForMap(CodegenProperty property)
Update datatypeWithEnum for map container- Parameters:
property- Codegen property
-
setNonArrayMapProperty
protected void setNonArrayMapProperty(CodegenProperty property, String type)
-
findMethodResponse
protected io.swagger.v3.oas.models.responses.ApiResponse findMethodResponse(io.swagger.v3.oas.models.responses.ApiResponses responses)
Override with any special handling of response codes- Parameters:
responses- OAS Operation's responses- Returns:
- default method response or
nullif not found
-
handleMethodResponse
protected void handleMethodResponse(io.swagger.v3.oas.models.Operation operation, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, CodegenOperation op, io.swagger.v3.oas.models.responses.ApiResponse methodResponse)Set op's returnBaseType, returnType, examples etc.- Parameters:
operation- endpoint Operationschemas- a map of the schemas in the openapi specop- endpoint CodegenOperationmethodResponse- the default ApiResponse for the endpoint
-
handleMethodResponse
protected void handleMethodResponse(io.swagger.v3.oas.models.Operation operation, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, CodegenOperation op, io.swagger.v3.oas.models.responses.ApiResponse methodResponse, Map<String,String> schemaMappings)Set op's returnBaseType, returnType, examples etc.- Parameters:
operation- endpoint Operationschemas- a map of the schemas in the openapi specop- endpoint CodegenOperationmethodResponse- the default ApiResponse for the endpointschemaMappings- mappings of external types to be omitted by unaliasing
-
fromOperation
public CodegenOperation fromOperation(String path, String httpMethod, io.swagger.v3.oas.models.Operation operation, List<io.swagger.v3.oas.models.servers.Server> servers)
Convert OAS Operation object to Codegen Operation object- Specified by:
fromOperationin interfaceCodegenConfig- Parameters:
httpMethod- HTTP methodoperation- OAS operation objectpath- the path of the operationservers- list of servers- Returns:
- Codegen Operation object
-
isParameterNameUnique
public boolean isParameterNameUnique(CodegenParameter p, List<CodegenParameter> parameters)
-
fromResponse
public CodegenResponse fromResponse(String responseCode, io.swagger.v3.oas.models.responses.ApiResponse response)
Convert OAS Response object to Codegen Response object- Parameters:
responseCode- HTTP response coderesponse- OAS Response object- Returns:
- Codegen Response object
-
fromCallback
public CodegenCallback fromCallback(String name, io.swagger.v3.oas.models.callbacks.Callback callback, List<io.swagger.v3.oas.models.servers.Server> servers)
Convert OAS Callback object to Codegen Callback object- Parameters:
name- callback namecallback- OAS Callback objectservers- list of servers- Returns:
- Codegen Response object
-
updateParameterForString
protected void updateParameterForString(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema parameterSchema)
-
fromParameter
public CodegenParameter fromParameter(io.swagger.v3.oas.models.parameters.Parameter parameter, Set<String> imports)
Convert OAS Parameter object to Codegen Parameter object- Parameters:
parameter- OAS parameter objectimports- set of imports for library/package/module- Returns:
- Codegen Parameter object
-
getParameterDataType
protected String getParameterDataType(io.swagger.v3.oas.models.parameters.Parameter parameter, io.swagger.v3.oas.models.media.Schema schema)
Returns the data type of parameter. Returns null by default to use the CodegenProperty.datatype value- Parameters:
parameter- Parameterschema- Schema- Returns:
- data type
-
isDataTypeBinary
public boolean isDataTypeBinary(String dataType)
-
isDataTypeFile
public boolean isDataTypeFile(String dataType)
-
fromSecurity
public List<CodegenSecurity> fromSecurity(Map<String,io.swagger.v3.oas.models.security.SecurityScheme> securitySchemeMap)
Convert map of OAS SecurityScheme objects to a list of Codegen Security objects- Specified by:
fromSecurityin interfaceCodegenConfig- Parameters:
securitySchemeMap- a map of OAS SecuritySchemeDefinition object- Returns:
- a list of Codegen Security objects
-
isReservedWord
protected boolean isReservedWord(String word)
-
getOrGenerateOperationId
protected String getOrGenerateOperationId(io.swagger.v3.oas.models.Operation operation, String path, String httpMethod)
Get operationId from the operation object, and if it's blank, generate a new one from the given parameters.- Parameters:
operation- the operation objectpath- the path of the operationhttpMethod- the HTTP method of the operation- Returns:
- the (generated) operationId
-
needToImport
protected boolean needToImport(String type)
Check the type to see if it needs import the library/module/package- Parameters:
type- name of the type- Returns:
- true if the library/module/package of the corresponding type needs to be imported
-
addHeaders
protected void addHeaders(io.swagger.v3.oas.models.responses.ApiResponse response, List<CodegenProperty> properties)Add headers to codegen property- Parameters:
response- API responseproperties- list of codegen property
-
addOperationToGroup
public void addOperationToGroup(String tag, String resourcePath, io.swagger.v3.oas.models.Operation operation, CodegenOperation co, Map<String,List<CodegenOperation>> operations)
Add operation to group- Specified by:
addOperationToGroupin interfaceCodegenConfig- Parameters:
tag- name of the tagresourcePath- path of the resourceoperation- OAS Operation objectco- Codegen Operation objectoperations- map of Codegen operations
-
addParentContainer
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, based on the value of the 'additionalProperties' keyword. Some language generator use class inheritance to implement additional properties. For example, in Java the generated model class has 'extends HashMap' to represent the additional properties.TODO: it's not a good idea to use single class inheritance to implement additionalProperties. That may work for non-composed schemas, but that does not work for composed 'allOf' schemas. For example, in Java, if additionalProperties is set to true (which it should be by default, per OAS spec), then the generated code has extends HashMap. That wouldn't work for composed 'allOf' schemas.
- Parameters:
model- the codegen representation of the OAS schema.name- the name of the model.schema- the input OAS schema.
-
addImports
protected void addImports(CodegenModel m, IJsonSchemaValidationProperties type)
-
addImports
protected void addImports(Set<String> importsToBeAddedTo, IJsonSchemaValidationProperties type)
-
addImport
protected void addImport(CodegenModel m, String type)
-
addImport
protected void addImport(io.swagger.v3.oas.models.media.ComposedSchema composed, io.swagger.v3.oas.models.media.Schema childSchema, CodegenModel model, String modelName)Add the model name of the child schema in a composed schema to the set of imports- Parameters:
composed- composed schemachildSchema- composed schemamodel- codegen modelmodelName- model name
-
shouldAddImport
protected boolean shouldAddImport(String type)
-
unaliasPropertySchema
protected Map<String,io.swagger.v3.oas.models.media.Schema> unaliasPropertySchema(Map<String,io.swagger.v3.oas.models.media.Schema> properties)
Loop through properties and unalias the reference if $ref (reference) is defined- Parameters:
properties- model properties (schemas)- Returns:
- model properties with direct reference to schemas
-
addVars
protected void addVars(CodegenModel m, Map<String,io.swagger.v3.oas.models.media.Schema> properties, List<String> required, Map<String,io.swagger.v3.oas.models.media.Schema> allProperties, List<String> allRequired)
-
addVars
protected void addVars(IJsonSchemaValidationProperties m, List<CodegenProperty> vars, Map<String,io.swagger.v3.oas.models.media.Schema> properties, Set<String> mandatory)
Add variables (properties) to codegen model (list of properties, various flags, etc)- Parameters:
m- Must be an instance of IJsonSchemaValidationProperties, may be model or property...vars- list of codegen properties (e.g. vars, allVars) to be updated with the new propertiesproperties- a map of properties (schema)mandatory- a set of required properties' name
-
addImportsForPropertyType
protected void addImportsForPropertyType(CodegenModel model, CodegenProperty property)
For a given property, adds all needed imports to the model This includes a flat property type (e.g. property type: ReferencedModel) as well as container type (property type: array of ReferencedModel's)- Parameters:
model- The codegen representation of the OAS schema.property- The codegen representation of the OAS schema's property.
-
removeNonNameElementToCamelCase
public String removeNonNameElementToCamelCase(String name)
Remove characters not suitable for variable or method name from the input and camelize it- Parameters:
name- string to be camelize- Returns:
- camelized string
-
removeNonNameElementToCamelCase
protected String removeNonNameElementToCamelCase(String name, String nonNameElementPattern)
Remove characters that is not good to be included in method name from the input and camelize it- Parameters:
name- string to be camelizenonNameElementPattern- a regex pattern of the characters that is not good to be included in name- Returns:
- camelized string
-
apiFilename
public String apiFilename(String templateName, String tag)
- Specified by:
apiFilenamein interfaceCodegenConfig
-
modelFilename
public String modelFilename(String templateName, String modelName)
- Specified by:
modelFilenamein interfaceCodegenConfig
-
apiDocFilename
public String apiDocFilename(String templateName, String tag)
Return the full path and API documentation file- Specified by:
apiDocFilenamein interfaceCodegenConfig- Parameters:
templateName- template nametag- tag- Returns:
- the API documentation file name with full path
-
apiTestFilename
public String apiTestFilename(String templateName, String tag)
Return the full path and API test file- Specified by:
apiTestFilenamein interfaceCodegenConfig- Parameters:
templateName- template nametag- tag- Returns:
- the API test file name with full path
-
shouldOverwrite
public boolean shouldOverwrite(String filename)
- Specified by:
shouldOverwritein interfaceCodegenConfig
-
isSkipOverwrite
public boolean isSkipOverwrite()
- Specified by:
isSkipOverwritein interfaceCodegenConfig
-
setSkipOverwrite
public void setSkipOverwrite(boolean skipOverwrite)
- Specified by:
setSkipOverwritein interfaceCodegenConfig
-
isRemoveOperationIdPrefix
public boolean isRemoveOperationIdPrefix()
- Specified by:
isRemoveOperationIdPrefixin interfaceCodegenConfig
-
isSkipOperationExample
public boolean isSkipOperationExample()
- Specified by:
isSkipOperationExamplein interfaceCodegenConfig
-
setRemoveOperationIdPrefix
public void setRemoveOperationIdPrefix(boolean removeOperationIdPrefix)
- Specified by:
setRemoveOperationIdPrefixin interfaceCodegenConfig
-
getRemoveOperationIdPrefixDelimiter
public String getRemoveOperationIdPrefixDelimiter()
-
setRemoveOperationIdPrefixDelimiter
public void setRemoveOperationIdPrefixDelimiter(String removeOperationIdPrefixDelimiter)
-
getRemoveOperationIdPrefixCount
public int getRemoveOperationIdPrefixCount()
-
setRemoveOperationIdPrefixCount
public void setRemoveOperationIdPrefixCount(int removeOperationIdPrefixCount)
-
setSkipOperationExample
public void setSkipOperationExample(boolean skipOperationExample)
- Specified by:
setSkipOperationExamplein interfaceCodegenConfig
-
isHideGenerationTimestamp
public boolean isHideGenerationTimestamp()
- Specified by:
isHideGenerationTimestampin interfaceCodegenConfig
-
setHideGenerationTimestamp
public void setHideGenerationTimestamp(boolean hideGenerationTimestamp)
- Specified by:
setHideGenerationTimestampin interfaceCodegenConfig
-
supportedLibraries
public Map<String,String> supportedLibraries()
All library templates supported. (key: library name, value: library description)- Specified by:
supportedLibrariesin interfaceCodegenConfig- Returns:
- the supported libraries
-
setLibrary
public void setLibrary(String library)
Set library template (sub-template).- Specified by:
setLibraryin interfaceCodegenConfig- Parameters:
library- Library template
-
getLibrary
public String getLibrary()
Library template (sub-template).- Specified by:
getLibraryin interfaceCodegenConfig- Returns:
- Library template
-
isLibrary
public final boolean isLibrary(String library)
check if current active library equals to passed- Parameters:
library- - library to be compared with- Returns:
trueif passed library is active,falseotherwise
-
setGitHost
public void setGitHost(String gitHost)
Set Git host.- Specified by:
setGitHostin interfaceCodegenConfig- Parameters:
gitHost- Git host
-
getGitHost
public String getGitHost()
Git host.- Specified by:
getGitHostin interfaceCodegenConfig- Returns:
- Git host
-
setGitUserId
public void setGitUserId(String gitUserId)
Set Git user ID.- Specified by:
setGitUserIdin interfaceCodegenConfig- Parameters:
gitUserId- Git user ID
-
getGitUserId
public String getGitUserId()
Git user ID- Specified by:
getGitUserIdin interfaceCodegenConfig- Returns:
- Git user ID
-
setGitRepoId
public void setGitRepoId(String gitRepoId)
Set Git repo ID.- Specified by:
setGitRepoIdin interfaceCodegenConfig- Parameters:
gitRepoId- Git repo ID
-
getGitRepoId
public String getGitRepoId()
Git repo ID- Specified by:
getGitRepoIdin interfaceCodegenConfig- Returns:
- Git repo ID
-
setReleaseNote
public void setReleaseNote(String releaseNote)
Set release note.- Specified by:
setReleaseNotein interfaceCodegenConfig- Parameters:
releaseNote- Release note
-
getReleaseNote
public String getReleaseNote()
Release note- Specified by:
getReleaseNotein interfaceCodegenConfig- Returns:
- Release note
-
getDocExtension
public String getDocExtension()
Documentation files extension- Specified by:
getDocExtensionin interfaceCodegenConfig- Returns:
- Documentation files extension
-
setDocExtension
public void setDocExtension(String userDocExtension)
Set Documentation files extension- Specified by:
setDocExtensionin interfaceCodegenConfig- Parameters:
userDocExtension- documentation files extension
-
setHttpUserAgent
public void setHttpUserAgent(String httpUserAgent)
Set HTTP user agent.- Specified by:
setHttpUserAgentin interfaceCodegenConfig- Parameters:
httpUserAgent- HTTP user agent
-
getHttpUserAgent
public String getHttpUserAgent()
HTTP user agent- Specified by:
getHttpUserAgentin interfaceCodegenConfig- Returns:
- HTTP user agent
-
buildLibraryCliOption
protected CliOption buildLibraryCliOption(Map<String,String> supportedLibraries)
-
sanitizeName
public String sanitizeName(String name)
Sanitize name (parameter, property, method, etc)- Specified by:
sanitizeNamein interfaceCodegenConfig- Parameters:
name- string to be sanitize- Returns:
- sanitized string
-
setTemplatingEngine
public void setTemplatingEngine(TemplatingEngineAdapter templatingEngine)
- Specified by:
setTemplatingEnginein interfaceCodegenConfig
-
getTemplatingEngine
public TemplatingEngineAdapter getTemplatingEngine()
- Specified by:
getTemplatingEnginein interfaceCodegenConfig
-
sanitizeName
public String sanitizeName(String name, String removeCharRegEx)
Sanitize name (parameter, property, method, etc)- Parameters:
name- string to be sanitizeremoveCharRegEx- a regex containing all char that will be removed- Returns:
- sanitized string
-
sanitizeName
public String sanitizeName(String name, String removeCharRegEx, ArrayList<String> exceptionList)
Sanitize name (parameter, property, method, etc)- Parameters:
name- string to be sanitizeremoveCharRegEx- a regex containing all char that will be removedexceptionList- a list of matches which should not be sanitized (i.e exception)- Returns:
- sanitized string
-
sanitizeTag
public String sanitizeTag(String tag)
Sanitize tag- Specified by:
sanitizeTagin interfaceCodegenConfig- Parameters:
tag- Tag- Returns:
- Sanitized tag
-
setParameterBooleanFlagWithCodegenProperty
public void setParameterBooleanFlagWithCodegenProperty(CodegenParameter parameter, CodegenProperty property)
Set CodegenParameter boolean flag using CodegenProperty. NOTE: This is deprecated and can be removed in 6.0.0 This logic has been folded into the original call sites and long term will be moved into IJsonSchemaValidationProperties.setTypeProperties and overrides like updateModelForObject- Parameters:
parameter- Codegen Parameterproperty- Codegen property
-
updateCodegenPropertyEnum
public void updateCodegenPropertyEnum(CodegenProperty var)
Update codegen property's enum by adding "enumVars" (with name and value)- Parameters:
var- list of CodegenProperty
-
buildEnumVars
protected List<Map<String,Object>> buildEnumVars(List<Object> values, String dataType)
-
updateEnumVarsWithExtensions
protected void updateEnumVarsWithExtensions(List<Map<String,Object>> enumVars, Map<String,Object> vendorExtensions, String dataType)
-
addRegularExpressionDelimiter
public String addRegularExpressionDelimiter(String pattern)
If the pattern misses the delimiter, add "/" to the beginning and end Otherwise, return the original pattern- Parameters:
pattern- the pattern (regular expression)- Returns:
- the pattern with delimiter
-
convertPropertyToBooleanAndWriteBack
public boolean convertPropertyToBooleanAndWriteBack(String propertyKey)
reads propertyKey from additionalProperties, converts it to a boolean and writes it back to additionalProperties to be usable as a boolean in mustache files.- Parameters:
propertyKey- property key- Returns:
- property value as boolean
-
getIgnoreFilePathOverride
public String getIgnoreFilePathOverride()
Provides an override location, if any is specified, for the .openapi-generator-ignore.This is originally intended for the first generation only.
- Specified by:
getIgnoreFilePathOverridein interfaceCodegenConfig- Returns:
- a string of the full path to an override ignore file.
-
setIgnoreFilePathOverride
public void setIgnoreFilePathOverride(String ignoreFileOverride)
Sets an override location for the '.openapi-generator-ignore' location for the first code generation.- Specified by:
setIgnoreFilePathOverridein interfaceCodegenConfig- Parameters:
ignoreFileOverride- The full path to an ignore file
-
convertPropertyToBoolean
public boolean convertPropertyToBoolean(String propertyKey)
-
getContentType
protected String getContentType(io.swagger.v3.oas.models.parameters.RequestBody requestBody)
-
getConsumesInfo
public static Set<String> getConsumesInfo(io.swagger.v3.oas.models.OpenAPI openAPI, io.swagger.v3.oas.models.Operation operation)
-
hasFormParameter
public boolean hasFormParameter(io.swagger.v3.oas.models.Operation operation)
-
hasBodyParameter
public boolean hasBodyParameter(io.swagger.v3.oas.models.Operation operation)
-
getProducesInfo
public static Set<String> getProducesInfo(io.swagger.v3.oas.models.OpenAPI openAPI, io.swagger.v3.oas.models.Operation operation)
returns the list of MIME types the APIs can produce- Parameters:
openAPI- current specification instanceoperation- Operation- Returns:
- a set of MIME types
-
getCollectionFormat
protected String getCollectionFormat(io.swagger.v3.oas.models.parameters.Parameter parameter)
-
getTag
public CodegenType getTag()
- Specified by:
getTagin interfaceCodegenConfig
-
getName
public String getName()
- Specified by:
getNamein interfaceCodegenConfig
-
getHelp
public String getHelp()
- Specified by:
getHelpin interfaceCodegenConfig
-
fromRequestBodyToFormParameters
public List<CodegenParameter> fromRequestBodyToFormParameters(io.swagger.v3.oas.models.parameters.RequestBody body, Set<String> imports)
-
fromFormProperty
public CodegenParameter fromFormProperty(String name, io.swagger.v3.oas.models.media.Schema propertySchema, Set<String> imports)
-
addBodyModelSchema
protected void addBodyModelSchema(CodegenParameter codegenParameter, String name, io.swagger.v3.oas.models.media.Schema schema, Set<String> imports, String bodyParameterName, boolean forceSimpleRef)
-
updateRequestBodyForMap
protected void updateRequestBodyForMap(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String name, Set<String> imports, String bodyParameterName)
-
updateRequestBodyForPrimitiveType
protected void updateRequestBodyForPrimitiveType(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String bodyParameterName, Set<String> imports)
-
updateRequestBodyForObject
protected void updateRequestBodyForObject(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String name, Set<String> imports, String bodyParameterName)
-
updateRequestBodyForArray
protected void updateRequestBodyForArray(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, String name, Set<String> imports, String bodyParameterName)
-
updateRequestBodyForString
protected void updateRequestBodyForString(CodegenParameter codegenParameter, io.swagger.v3.oas.models.media.Schema schema, Set<String> imports, String bodyParameterName)
-
toMediaTypeSchemaName
protected String toMediaTypeSchemaName(String contentType, String mediaTypeSchemaSuffix)
-
getContent
protected LinkedHashMap<String,CodegenMediaType> getContent(io.swagger.v3.oas.models.media.Content content, Set<String> imports, String mediaTypeSchemaSuffix)
-
fromRequestBody
public CodegenParameter fromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody body, Set<String> imports, String bodyParameterName)
-
addRequiredVarsMap
protected void addRequiredVarsMap(io.swagger.v3.oas.models.media.Schema schema, IJsonSchemaValidationProperties property)
-
addVarsRequiredVarsAdditionalProps
protected void addVarsRequiredVarsAdditionalProps(io.swagger.v3.oas.models.media.Schema schema, IJsonSchemaValidationProperties property)
-
getItemsName
protected String getItemsName(io.swagger.v3.oas.models.media.Schema containingSchema, String containingSchemaName)
-
getAdditionalPropertiesName
protected String getAdditionalPropertiesName()
-
addOption
protected void addOption(String key, String description, String defaultValue, Map<String,String> enumValues)
-
removeOption
protected void removeOption(String key)
-
generateJSONSpecFile
protected void generateJSONSpecFile(Map<String,Object> objs)
generates OpenAPI specification file in JSON format- Parameters:
objs- map of object
-
generateYAMLSpecFile
public void generateYAMLSpecFile(Map<String,Object> objs)
generates OpenAPI specification file in YAML format- Parameters:
objs- map of object
-
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"- Parameters:
dataType- data type- Returns:
- true if it's a enum string
-
fromServers
public List<CodegenServer> fromServers(List<io.swagger.v3.oas.models.servers.Server> servers)
- Specified by:
fromServersin interfaceCodegenConfig
-
fromServerVariables
public List<CodegenServerVariable> fromServerVariables(Map<String,io.swagger.v3.oas.models.servers.ServerVariable> variables)
- Specified by:
fromServerVariablesin interfaceCodegenConfig
-
setParameterNullable
protected void setParameterNullable(CodegenParameter parameter, CodegenProperty property)
-
postProcessFile
public void postProcessFile(File file, String fileType)
Post-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-mustache", "supporting-common", "openapi-generator-ignore", "openapi-generator-version"TODO: store these values in enum instead
- Specified by:
postProcessFilein interfaceCodegenConfig- Parameters:
file- file to be processedfileType- file type
-
isEnablePostProcessFile
public boolean isEnablePostProcessFile()
Boolean value indicating the state of the option for post-processing file using environment variables.- Specified by:
isEnablePostProcessFilein interfaceCodegenConfig- Returns:
- true if the option is enabled
-
setEnablePostProcessFile
public void setEnablePostProcessFile(boolean enablePostProcessFile)
Set the boolean value indicating the state of the option for post-processing file using environment variables.- Specified by:
setEnablePostProcessFilein interfaceCodegenConfig- Parameters:
enablePostProcessFile- true to enable post-processing file
-
isEnableMinimalUpdate
public boolean isEnableMinimalUpdate()
Get the boolean value indicating the state of the option for updating only changed files- Specified by:
isEnableMinimalUpdatein interfaceCodegenConfig
-
setEnableMinimalUpdate
public void setEnableMinimalUpdate(boolean enableMinimalUpdate)
Set the boolean value indicating the state of the option for updating only changed files- Specified by:
setEnableMinimalUpdatein interfaceCodegenConfig- Parameters:
enableMinimalUpdate- true to enable minimal update
-
isStrictSpecBehavior
public boolean isStrictSpecBehavior()
Indicates whether the codegen configuration should treat documents as strictly defined by the OpenAPI specification.- Specified by:
isStrictSpecBehaviorin interfaceCodegenConfig- Returns:
- true to act strictly upon spec documents, potentially modifying the spec to strictly fit the spec.
-
setStrictSpecBehavior
public void setStrictSpecBehavior(boolean strictSpecBehavior)
Sets the boolean valid indicating whether generation will work strictly against the specification, potentially making minor changes to the input document.- Specified by:
setStrictSpecBehaviorin interfaceCodegenConfig- Parameters:
strictSpecBehavior- true if we will behave strictly, false to allow specification documents which pass validation to be loosely interpreted against the spec.
-
getFeatureSet
public FeatureSet getFeatureSet()
- Specified by:
getFeatureSetin interfaceCodegenConfig
-
isRemoveEnumValuePrefix
public boolean isRemoveEnumValuePrefix()
Get the boolean value indicating whether to remove enum value prefixes- Specified by:
isRemoveEnumValuePrefixin interfaceCodegenConfig
-
setRemoveEnumValuePrefix
public void setRemoveEnumValuePrefix(boolean removeEnumValuePrefix)
Set the boolean value indicating whether to remove enum value prefixes- Specified by:
setRemoveEnumValuePrefixin interfaceCodegenConfig- Parameters:
removeEnumValuePrefix- true to enable enum value prefix removal
-
addOneOfNameExtension
public void addOneOfNameExtension(io.swagger.v3.oas.models.media.ComposedSchema s, String name)Add "x-one-of-name" extension to a given oneOf schema (assuming it has at least 1 oneOf elements)- Parameters:
s- schema to add the extension toname- name of the parent oneOf schema
-
addOneOfInterfaceModel
public void addOneOfInterfaceModel(io.swagger.v3.oas.models.media.ComposedSchema cs, String type)Add a given ComposedSchema as an interface model to be generated, assuming it has `oneOf` defined- Parameters:
cs- ComposedSchema object to create as interface modeltype- name to use for the generated interface model
-
addImportsToOneOfInterface
public void addImportsToOneOfInterface(List<Map<String,String>> imports)
-
modifyFeatureSet
protected void modifyFeatureSet(Consumer<FeatureSet.Builder> processor)
-
isAnyTypeSchema
public boolean isAnyTypeSchema(io.swagger.v3.oas.models.media.Schema schema)
This method has been kept to keep the introduction of ModelUtils.isAnyType as a non-breaking change this way, existing forks of our generator can continue to use this method TODO in 6.0.0 replace this method with ModelUtils.isAnyType Return true if the schema value can be any type, i.e. it can be the null value, integer, number, string, object or array. One use case is when the "type" attribute in the OAS schema is unspecified. Examples: arbitraryTypeValue: description: This is an arbitrary type schema. It is not a free-form object. The value can be any type except the 'null' value. arbitraryTypeNullableValue: description: This is an arbitrary type schema. It is not a free-form object. The value can be any type, including the 'null' value. nullable: true- Parameters:
schema- the OAS schema.- Returns:
- true if the schema value can be an arbitrary type.
-
isJsonMimeType
public static boolean isJsonMimeType(String mime)
Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON- Parameters:
mime- MIME string- Returns:
- true if the input matches the JSON MIME
-
isXmlMimeType
public static boolean isXmlMimeType(String mime)
-
isJsonVendorMimeType
protected static boolean isJsonVendorMimeType(String mime)
Check if the given MIME is a JSON Vendor MIME. JSON MIME examples: application/vnd.mycompany+json application/vnd.mycompany.resourceA.version1+json- Parameters:
mime- MIME string- Returns:
- true if the input matches the JSON vendor MIME
-
getCollectionFormat
protected String getCollectionFormat(CodegenParameter codegenParameter)
Builds OAPI 2.0 collectionFormat value based on style and explode values for theCodegenParameter.- Parameters:
codegenParameter- parameter- Returns:
- string for a collectionFormat.
-
defaultTemplatingEngine
public String defaultTemplatingEngine()
- Specified by:
defaultTemplatingEnginein interfaceCodegenConfig
-
generatorLanguage
public GeneratorLanguage generatorLanguage()
- Specified by:
generatorLanguagein interfaceCodegenConfig
-
generatorLanguageVersion
public String generatorLanguageVersion()
- Specified by:
generatorLanguageVersionin interfaceCodegenConfig
-
getSupportedVendorExtensions
public List<VendorExtension> getSupportedVendorExtensions()
- Specified by:
getSupportedVendorExtensionsin interfaceCodegenConfig
-
getUseInlineModelResolver
public boolean getUseInlineModelResolver()
- Specified by:
getUseInlineModelResolverin interfaceCodegenConfig
-
getUseOpenAPINormalizer
public boolean getUseOpenAPINormalizer()
- Specified by:
getUseOpenAPINormalizerin interfaceCodegenConfig
-
getSchemaFromBooleanOrSchema
protected io.swagger.v3.oas.models.media.Schema getSchemaFromBooleanOrSchema(Object schema)
Used to ensure that null or Schema is returned given an input Boolean/Schema/null This will be used in openapi 3.1.0 spec processing to ensure that Booleans become Schemas Because our generators only understand Schemas Note: use getIsBooleanSchemaTrue or getIsBooleanSchemaFalse on the IJsonSchemaValidationProperties if you need to be able to detect if the original schema's value was true or false- Parameters:
schema- the input Boolean or Schema data to convert to a Schema- Returns:
- Schema the input data converted to a Schema if possible
-
-