public abstract class AbstractRustCodegen extends DefaultCodegen implements CodegenConfig
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractRustCodegen.CasingType |
| Modifier and Type | Field and Description |
|---|---|
protected List<String> |
charactersToAllow |
protected String |
enumSuffix |
protected Set<String> |
keywordsThatDoNotSupportRawIdentifiers |
additionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, addSchemaImportsFromV3SpecLocations, addSuffixToDuplicateOperationNicknames, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, DefaultFeatureSet, defaultIncludes, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, enumUnknownDefaultCase, enumUnknownDefaultCaseName, falseSchema, filesMetadataFilename, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importBaseType, importContainerType, importMapping, inlineSchemaNameDefault, inlineSchemaNameMapping, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, loadDeepObjectIntoItems, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, openAPI, openapiNormalizer, outputFolder, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, removeOperationIdPrefixCount, removeOperationIdPrefixDelimiter, reservedWords, reservedWordsMappings, schemaMapping, serverVariables, skipOperationExample, skipOverwrite, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, testPackage, trueSchema, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions, versionMetadataFilename| Constructor and Description |
|---|
AbstractRustCodegen() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
addApiNamePrefixAndSuffix(String name) |
protected String |
addModelNamePrefixAndSuffix(String name) |
String |
bestFittingIntegerType(BigInteger minimum,
boolean exclusiveMinimum,
BigInteger maximum,
boolean exclusiveMaximum,
boolean preferUnsigned)
Determine the best fitting Rust type for an integer property.
|
boolean |
canFitIntoUnsigned(BigInteger minimum,
boolean exclusiveMinimum)
Determine if an integer property can be guaranteed to fit into an unsigned data type.
|
String |
escapeQuotationMark(String input)
Escape single and/or double quote to avoid code injection
|
String |
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe
characters so as to avoid code injection
|
GeneratorLanguage |
generatorLanguage() |
boolean |
isReservedWord(String word) |
String |
sanitizeIdentifier(String name,
AbstractRustCodegen.CasingType casingType,
String escapePrefix,
String type,
boolean allowRawIdentifiers)
General purpose sanitizing function for Rust identifiers (fields, variables, structs, parameters, etc.).
Rules for Rust are fairly simple: Characters must belong to [A-Za-z0-9_] Cannot use reserved words (but can sometimes prefix with "r#") Cannot begin with a number |
String |
toApiDocFilename(String name)
Return the file name of the Api Documentation
|
String |
toApiFilename(String name)
Return the file name of the Api Test
|
String |
toApiName(String name)
Output the API (class) name (capitalized) ending with the specified or default suffix
Return DefaultApi if name is empty
|
String |
toEnumDefaultValue(String value,
String datatype)
Return the enum default value in the language specified format
|
String |
toEnumName(CodegenProperty property)
Return the Enum name (e.g.
|
String |
toEnumValue(String value,
String datatype)
Return the enum value in the language specified format
e.g.
|
String |
toEnumVarName(String name,
String datatype)
Return the sanitized variable name for enum
|
String |
toModelDocFilename(String name)
Return the capitalized file name of the model documentation
|
String |
toModelFilename(String name)
Return the capitalized file name of the model
|
String |
toModelName(String name)
Converts the OpenAPI schema name to a model name suitable for the current code generator.
|
String |
toOperationId(String operationId)
Return the operation ID (method name)
|
String |
toParamName(String name)
Return the parameter name by removing invalid characters and proper escaping if
it's a reserved word.
|
String |
toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if
it's a reserved word.
|
addAdditionPropertiesToCodeGenModel, addBodyModelSchema, addHeaders, addImport, addImport, addImport, addImports, addImports, addImports, addImportsForPropertyType, addImportsToOneOfInterface, additionalProperties, addMustacheLambdas, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addParentContainer, addProperties, addRegularExpressionDelimiter, addRequiredVarsMap, addSwitch, addVars, addVars, addVarsRequiredVarsAdditionalProps, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, createDiscriminator, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, escapeReservedWord, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromModel, fromOperation, fromParameter, fromProperty, fromProperty, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, generatorLanguageVersion, getAdditionalProperties, getAdditionalPropertiesName, getAddSuffixToDuplicateOperationNicknames, getAlias, getAllModels, getAllOfDescendants, getAllowUnicodeIdentifiers, getApiNamePrefix, getApiNameSuffix, getCollectionFormat, getCollectionFormat, getConsumesInfo, getContent, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDocExtension, getEnsureUniqueParams, getEnumDefaultValue, getEnumUnknownDefaultCase, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getItemsName, getLegacyDiscriminatorBehavior, getLibrary, getModelNamePrefix, getModelNameSuffix, getModelNameToSchemaCache, getMostInnerItems, getName, getOneOfAnyOfDescendants, getOrGenerateOperationId, getOutputDir, getParameterDataType, getPrependFormOrBodyParameters, getProducesInfo, getReleaseNote, getRemoveOperationIdPrefixCount, getRemoveOperationIdPrefixDelimiter, getSchemaAdditionalProperties, getSchemaFromBooleanOrSchema, getSchemaItems, getSchemaType, getSingleSchemaType, getSortModelPropertiesByRequiredFlag, getSortParamsByRequiredFlag, getSupportedVendorExtensions, getSymbolName, getTag, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getTypeDeclaration, getUseInlineModelResolver, getUseOneOfInterfaces, getUseOpenAPINormalizer, getVersionMetadataFilename, handleMethodResponse, handleMethodResponse, handleSpecialCharacters, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, inlineSchemaNameDefault, inlineSchemaNameMapping, instantiationTypes, isAnyTypeSchema, isDataTypeBinary, isDataTypeFile, isDataTypeString, isEnableMinimalUpdate, isEnablePostProcessFile, isFreeFormObject, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, lowerCamelCase, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, modifyFeatureSet, needToImport, openapiNormalizer, outputFolder, postProcess, postProcessAllModels, postProcessFile, postProcessModelProperty, postProcessModels, postProcessModelsEnum, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processOpts, processTemplatingEngine, processTestExampleData, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, removeSelfReferenceImports, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setAddProps, setAllowUnicodeIdentifiers, setApiNamePrefix, setApiNameSuffix, setApiPackage, setCircularReferences, setDisallowAdditionalPropertiesIfNotPresent, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnsureUniqueParams, setEnumUnknownDefaultCase, setFilesMetadataFilename, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLegacyDiscriminatorBehavior, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterEncodingValues, setParameterExampleValue, setParameterExampleValue, setParameterExampleValue, setParameterNullable, setPrependFormOrBodyParameters, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setRemoveOperationIdPrefixCount, setRemoveOperationIdPrefixDelimiter, setReservedWordsLowerCase, setSkipOperationExample, setSkipOverwrite, setSortModelPropertiesByRequiredFlag, setSortParamsByRequiredFlag, setStrictSpecBehavior, setTemplateDir, setTemplatingEngine, setUseOneOfInterfaces, setVersionMetadataFilename, shouldAddImport, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toAllOfName, toAnyOfName, toApiImport, toApiTestFilename, toApiVarName, toArrayModelParamName, toBooleanGetter, toDefaultParameterValue, toDefaultValue, toDefaultValue, toDefaultValueWithParam, toExamples, toExampleValue, toGetter, toInstantiationType, toMediaTypeSchemaName, toModelImport, toModelImportMap, toModelTestFilename, toOneOfName, toRegularExpression, toSetter, toTestCaseName, typeMapping, unaliasPropertySchema, unaliasSchema, updateAllModels, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updateEnumVarsWithExtensions, updateModelForAnyType, updateModelForComposedSchema, updateModelForInteger, updateModelForNumber, updateModelForObject, updateModelForString, updateOption, updateParameterForString, updatePropertyForAnyType, updatePropertyForArray, updatePropertyForInteger, updatePropertyForMap, updatePropertyForMap, updatePropertyForNumber, updatePropertyForObject, updatePropertyForString, updateRequestBodyForArray, updateRequestBodyForMap, updateRequestBodyForObject, updateRequestBodyForPrimitiveType, updateRequestBodyForString, vendorExtensions, writePropertyBackclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadditionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, escapeReservedWord, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromModel, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generatorLanguageVersion, getAddSuffixToDuplicateOperationNicknames, getDocExtension, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getName, getOutputDir, getReleaseNote, getSupportedVendorExtensions, getTag, getTemplatingEngine, getTypeDeclaration, getTypeDeclaration, getUseInlineModelResolver, getUseOpenAPINormalizer, getVersionMetadataFilename, importMapping, inlineSchemaNameDefault, inlineSchemaNameMapping, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, openapiNormalizer, outputFolder, postProcess, postProcessAllModels, postProcessFile, postProcessModelProperty, postProcessModels, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processOpts, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOperationExample, setSkipOverwrite, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toApiImport, toApiTestFilename, toApiVarName, toBooleanGetter, toGetter, toModelImport, toModelImportMap, toModelTestFilename, toSetter, typeMapping, unaliasSchema, updateAllModels, vendorExtensionsprotected String enumSuffix
public GeneratorLanguage generatorLanguage()
generatorLanguage in interface CodegenConfiggeneratorLanguage in class DefaultCodegenpublic String escapeQuotationMark(String input)
DefaultCodegenescapeQuotationMark in interface CodegenConfigescapeQuotationMark in class DefaultCodegeninput - String to be cleaned uppublic String escapeUnsafeCharacters(String input)
DefaultCodegenescapeUnsafeCharacters in interface CodegenConfigescapeUnsafeCharacters in class DefaultCodegeninput - String to be cleaned uppublic boolean isReservedWord(String word)
isReservedWord in class DefaultCodegenpublic String bestFittingIntegerType(@Nullable BigInteger minimum, boolean exclusiveMinimum, @Nullable BigInteger maximum, boolean exclusiveMaximum, boolean preferUnsigned)
minimum - The minimum value as set in the specification.exclusiveMinimum - If the minimum value itself is excluded by the specification.maximum - The maximum value as set in the specification.exclusiveMaximum - If the maximum value itself is excluded by the specification.preferUnsigned - Use unsigned types where the effective minimum is greater than or equal to zero.public boolean canFitIntoUnsigned(@Nullable BigInteger minimum, boolean exclusiveMinimum)
minimum - The minimum value as set in the specification.exclusiveMinimum - If boundary values are excluded by the specification.public String sanitizeIdentifier(String name, AbstractRustCodegen.CasingType casingType, String escapePrefix, String type, boolean allowRawIdentifiers)
name - The input stringcasingType - Which casing type to applyescapePrefix - Prefix to escape words beginning with numbers or reserved wordstype - The type of identifier (used for logging)allowRawIdentifiers - Raw identifiers can't always be used, because of filename vs import mismatch.public String toVarName(String name)
DefaultCodegentoVarName in class DefaultCodegenname - the variable namepublic String toParamName(String name)
DefaultCodegentoParamName in interface CodegenConfigtoParamName in class DefaultCodegenname - Codegen property objectpublic String toOperationId(String operationId)
DefaultCodegentoOperationId in class DefaultCodegenoperationId - operation IDpublic String toModelName(String name)
DefaultCodegentoModelName in interface CodegenConfigtoModelName in class DefaultCodegenname - the name of the modelpublic String toModelFilename(String name)
DefaultCodegentoModelFilename in interface CodegenConfigtoModelFilename in class DefaultCodegenname - the model namepublic String toModelDocFilename(String name)
DefaultCodegentoModelDocFilename in interface CodegenConfigtoModelDocFilename in class DefaultCodegenname - the model namepublic String toEnumVarName(String name, String datatype)
DefaultCodegentoEnumVarName in class DefaultCodegenname - enum variable namedatatype - data typepublic String toEnumName(CodegenProperty property)
DefaultCodegentoEnumName in class DefaultCodegenproperty - Codegen propertypublic String toEnumValue(String value, String datatype)
DefaultCodegentoEnumValue in class DefaultCodegenvalue - enum variable namedatatype - data typepublic String toEnumDefaultValue(String value, String datatype)
DefaultCodegentoEnumDefaultValue in class DefaultCodegenvalue - enum variable namedatatype - data typepublic String toApiName(String name)
DefaultCodegentoApiName in interface CodegenConfigtoApiName in class DefaultCodegenname - the name of the Apipublic String toApiFilename(String name)
DefaultCodegentoApiFilename in interface CodegenConfigtoApiFilename in class DefaultCodegenname - the file name of the Apipublic String toApiDocFilename(String name)
DefaultCodegentoApiDocFilename in interface CodegenConfigtoApiDocFilename in class DefaultCodegenname - the file name of the ApiCopyright © 2023. All rights reserved.