Class CppHttplibServerCodegen
- java.lang.Object
-
- org.openapitools.codegen.DefaultCodegen
-
- org.openapitools.codegen.languages.AbstractCppCodegen
-
- org.openapitools.codegen.languages.CppHttplibServerCodegen
-
- All Implemented Interfaces:
CodegenConfig
public class CppHttplibServerCodegen extends AbstractCppCodegen
C++ HTTP Library Server Code Generator. This code generator creates C++ server stubs using the httplib library for handling HTTP requests. It generates: - Model classes with proper C++ typing (std::string, std::vector, std::optional, etc.) - API handler interfaces with type-safe request/response handling - CMake build configuration - JSON serialization/deserialization using nlohmann::json Key features: - Supports nullable types using std::optional - Proper namespace organization for models and APIs - Status code to error type mapping for responses - Standard C++ container types (vector, map, etc.) - Automatic include generation for dependencies- Author:
- OpenAPI Generator Contributors
Mustache templates are located in
src/main/resources/cpp-httplib-server/.
-
-
Field Summary
Fields Modifier and Type Field Description static StringADD_API_IMPL_STUBSstatic StringAPI_NAMESPACEstatic StringAPI_SUFFIXstatic StringENUM_FROM_STRINGstatic StringENUM_NAMESPACEstatic StringENUM_SUFFIXstatic StringENUM_TO_STRINGstatic StringHTTP_RESPONSE_PREFIXstatic StringINCLUDE_OPTIONALstatic StringINCLUDE_VARIANTstatic StringMODEL_NAMESPACEstatic StringMODEL_SUFFIXstatic StringPRIMITIVE_FROM_STRINGstatic StringPRIMITIVE_TO_STRINGstatic StringPROJECT_NAME-
Fields inherited from class org.openapitools.codegen.languages.AbstractCppCodegen
RESERVED_WORD_PREFIX_DESC, RESERVED_WORD_PREFIX_OPTION, reservedWordPrefix, VARIABLE_NAME_FIRST_CHARACTER_UPPERCASE_DESC, VARIABLE_NAME_FIRST_CHARACTER_UPPERCASE_OPTION, variableNameFirstCharacterUppercase
-
Fields inherited from class org.openapitools.codegen.DefaultCodegen
additionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, addSuffixToDuplicateOperationNicknames, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, autosetConstants, cliOptions, DefaultFeatureSet, defaultIncludes, defaultToEmptyContainer, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, enumNameMapping, enumUnknownDefaultCase, enumUnknownDefaultCaseName, falseSchema, filesMetadataFilename, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importBaseType, importContainerType, importMapping, inlineSchemaNameMapping, inlineSchemaOption, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, loadDeepObjectIntoItems, modelDocTemplateFiles, modelNameMapping, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, nameMapping, openAPI, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, removeOperationIdPrefixCount, removeOperationIdPrefixDelimiter, reservedWords, reservedWordsMappings, schemaMapping, serverVariables, skipOperationExample, skipOverwrite, skipSortingOperations, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, SPLIT_ON_SEMICOLON_OR_NEWLINE_REGEX, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, templateOutputDirs, testPackage, trueSchema, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions, versionMetadataFilename, XML_MIME_PATTERN
-
-
Constructor Summary
Constructors Constructor Description CppHttplibServerCodegen()Constructor for CppHttplibServerCodegen.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddProjectOrDefaultName(String name, String defaultName)Adds project name to a class name or returns default name if project name is not set.StringapiFileFolder()Returns the directory path for generated API files.Stringcamelize(String name, boolean lowercaseFirstLetter)Converts a string to camelCase or PascalCase with proper case handling.CodegenModelfromModel(String name, io.swagger.v3.oas.models.media.Schema schema)Convert OAS Model object to Codegen Model object.StringgetHelp()Returns a brief description of what this code generator does.StringgetName()Returns the name identifier for this code generator.CodegenTypegetTag()StringgetTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)Output the language-specific type declaration of the property.StringmodelFileFolder()Returns the directory path for generated model files.Map<String,ModelsMap>postProcessAllModels(Map<String,ModelsMap> objs)Post-processes all models to add C++ specific configurations and namespace handling.voidpostProcessModelProperty(CodegenModel model, CodegenProperty property)OperationsMappostProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)Post-processes operations after model processing to add C++ specific configurations.voidpostProcessParameter(CodegenParameter parameter)Post-processes parameters to set up C++ specific configurations.Map<String,Object>postProcessSupportingFileData(Map<String,Object> objs)Post-processes supporting file data to conditionally add files based on API features.voidpreprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)voidprocessOpts()Processes command line options and additional properties.StringtoApiFilename(String name)Converts an API name to its corresponding filename.StringtoApiName(String name)Converts an API name to a C++ API class name.StringtoCamelCase(String name)Converts a string to camelCase formatting.StringtoDefaultValue(io.swagger.v3.oas.models.media.Schema p)Return the default value of the propertyStringtoHandlerFunctionName(String httpMethod, String path, Boolean prefix)Generates a handler function name from HTTP method and path.StringtoHandlerFunctionRequest(String path, String method)Generates a handler function request type from the API PathStringtoHandlerFunctionResponse(String path, String method)Generates a handler function response type from the API path.StringtoModelImport(String name)Converts a model name to its corresponding import statement.StringtoModelName(String name)Converts an OpenAPI model name to a C++ class name.StringtoModelNamespace(String modelNamespace)Converts a model namespace string to proper format.StringtoPascalCase(String name)Converts a string to PascalCase formatting with consistent handling.-
Methods inherited from class org.openapitools.codegen.languages.AbstractCppCodegen
addMustacheLambdas, escapeQuotationMark, escapeReservedWord, escapeUnsafeCharacters, fromProperty, generatorLanguage, getTypeDeclaration, postProcessFile, postProcessModels, sanitizeName, toBooleanGetter, toEnumValue, toOperationId, toParamName, toVarName
-
Methods inherited from class org.openapitools.codegen.DefaultCodegen
addAdditionPropertiesToCodeGenModel, addBodyModelSchema, addHeaders, addImport, addImport, addImport, addImports, addImports, addImports, addImportsForPropertyType, addImportsToOneOfInterface, additionalProperties, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addOption, addParentContainer, addParentFromContainer, addProperties, addRegularExpressionDelimiter, addRequiredVarsMap, addSwitch, addVars, addVars, addVarsRequiredVarsAdditionalProps, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, convertPropertyToBooleanAndWriteBack, convertPropertyToStringAndWriteBack, convertPropertyToTypeAndWriteBack, createDiscriminator, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextInSingleQuotes, escapeTextWhileAllowingNewLines, executePostProcessor, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromOperation, fromParameter, fromProperty, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, generatorLanguageVersion, getAdditionalPropertiesName, getAddSuffixToDuplicateOperationNicknames, getAlias, getAllModels, getAllOfDescendants, getCollectionFormat, getCollectionFormat, getConsumesInfo, getContent, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDiscriminatorPropertyType, getDiscriminatorSchema, getDocExtension, getEnumDefaultValue, getEnumUnknownDefaultCase, getEnumValueForProperty, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getItemsName, getLegacyDiscriminatorBehavior, getLibrary, getModelNameToSchemaCache, getMostInnerItems, getObjectAsStringList, getObjectAsStringListMap, getObjectAsStringMap, getOneOfAnyOfDescendants, getOpenapiGeneratorIgnoreList, getOrGenerateOperationId, getOutputDir, getParameterDataType, getProducesInfo, getPropertyAsStringList, getPropertyAsStringListMap, getPropertyAsStringMap, getReleaseNote, getSchemaAdditionalProperties, getSchemaFromBooleanOrSchema, getSchemaType, getSingleSchemaType, getSupportedVendorExtensions, getSymbolName, getTemplatingEngine, getterAndSetterCapitalize, getUseInlineModelResolver, getUseOneOfInterfaces, getUseOpenapiNormalizer, getVersionMetadataFilename, handleConstantParams, handleMethodResponse, handleMethodResponse, handleSpecialCharacters, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isDataTypeBinary, isDataTypeFile, isDataTypeString, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isReservedWord, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, isTypeErasedGenerics, isXmlMimeType, languageSpecificPrimitives, lowerCamelCase, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, modifyFeatureSet, nameMapping, needToImport, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessEnumVars, postProcessModelsEnum, postProcessResponseWithProperty, postProcessWebhooksWithModels, processCompiler, processOpenAPI, processTemplatingEngine, processTestExampleData, removeImport, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, removeSelfReferenceImports, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setAddProps, setCircularReferences, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnumDiscriminatorDefaultValue, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterEncodingValues, setParameterExamples, setParameterExampleValue, setParameterExampleValue, setParameterExampleValue, setParameterNullable, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setStrictSpecBehavior, setTemplatingEngine, setUseOneOfInterfaces, shouldAddImport, shouldOverwrite, SortModelPropertiesByRequiredFlag, SortParametersByRequiredFlag, specVersionGreaterThanOrEqualTo310, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toAllOfName, toAnyOfName, toApiDocFilename, toApiImport, toApiTestFilename, toApiVarName, toArrayModelParamName, toDefaultParameterValue, toDefaultParameterValue, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toEnumDefaultValue, toEnumName, toEnumVarName, toExamples, toExampleValue, toGetter, toInstantiationType, toMediaTypeSchemaName, toModelDocFilename, toModelFilename, 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, useCodegenAsMustacheParentContext, vendorExtensions, writePropertyBack
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openapitools.codegen.CodegenConfig
additionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generatorLanguageVersion, getAddSuffixToDuplicateOperationNicknames, getDocExtension, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getOpenapiGeneratorIgnoreList, getOutputDir, getReleaseNote, getSupportedVendorExtensions, getTemplatingEngine, getUseInlineModelResolver, getUseOpenapiNormalizer, getVersionMetadataFilename, importMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, isTypeErasedGenerics, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, nameMapping, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessResponseWithProperty, postProcessWebhooksWithModels, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeTag, schemaMapping, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toApiDocFilename, toApiImport, toApiTestFilename, toApiVarName, toGetter, toModelDocFilename, toModelFilename, toModelImportMap, toModelTestFilename, toSetter, typeMapping, unaliasSchema, updateAllModels, vendorExtensions
-
-
-
-
Field Detail
-
PROJECT_NAME
public static final String PROJECT_NAME
- See Also:
- Constant Field Values
-
MODEL_NAMESPACE
public static final String MODEL_NAMESPACE
- See Also:
- Constant Field Values
-
API_NAMESPACE
public static final String API_NAMESPACE
- See Also:
- Constant Field Values
-
ENUM_NAMESPACE
public static final String ENUM_NAMESPACE
- See Also:
- Constant Field Values
-
MODEL_SUFFIX
public static final String MODEL_SUFFIX
- See Also:
- Constant Field Values
-
API_SUFFIX
public static final String API_SUFFIX
- See Also:
- Constant Field Values
-
ENUM_SUFFIX
public static final String ENUM_SUFFIX
- See Also:
- Constant Field Values
-
INCLUDE_VARIANT
public static final String INCLUDE_VARIANT
- See Also:
- Constant Field Values
-
INCLUDE_OPTIONAL
public static final String INCLUDE_OPTIONAL
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_PREFIX
public static final String HTTP_RESPONSE_PREFIX
- See Also:
- Constant Field Values
-
ADD_API_IMPL_STUBS
public static final String ADD_API_IMPL_STUBS
- See Also:
- Constant Field Values
-
ENUM_FROM_STRING
public static final String ENUM_FROM_STRING
- See Also:
- Constant Field Values
-
ENUM_TO_STRING
public static final String ENUM_TO_STRING
- See Also:
- Constant Field Values
-
PRIMITIVE_FROM_STRING
public static final String PRIMITIVE_FROM_STRING
- See Also:
- Constant Field Values
-
PRIMITIVE_TO_STRING
public static final String PRIMITIVE_TO_STRING
- See Also:
- Constant Field Values
-
-
Method Detail
-
preprocessOpenAPI
public void preprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
- Specified by:
preprocessOpenAPIin interfaceCodegenConfig- Overrides:
preprocessOpenAPIin classAbstractCppCodegen
-
getTag
public CodegenType getTag()
- Specified by:
getTagin interfaceCodegenConfig- Overrides:
getTagin classDefaultCodegen
-
getName
public String getName()
Returns the name identifier for this code generator.- Specified by:
getNamein interfaceCodegenConfig- Overrides:
getNamein classDefaultCodegen- Returns:
- the generator name
-
getHelp
public String getHelp()
Returns a brief description of what this code generator does.- Specified by:
getHelpin interfaceCodegenConfig- Overrides:
getHelpin classDefaultCodegen- Returns:
- help text describing the generator's purpose
-
toModelImport
public String toModelImport(String name)
Converts a model name to its corresponding import statement. Handles both standard C++ types and custom model types.- Specified by:
toModelImportin interfaceCodegenConfig- Overrides:
toModelImportin classDefaultCodegen- Parameters:
name- the model name to import- Returns:
- the appropriate #include directive or empty string
-
postProcessOperationsWithModels
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)
Post-processes operations after model processing to add C++ specific configurations. This method: - Sets up class names and namespaces for API classes - Processes request and response models for each operation - Maps response status codes to their corresponding types - Collects all used models for proper include generation- Specified by:
postProcessOperationsWithModelsin interfaceCodegenConfig- Overrides:
postProcessOperationsWithModelsin classDefaultCodegen- Parameters:
objs- the operations map to processallModels- list of all models in the API- Returns:
- the processed operations map
-
postProcessAllModels
public Map<String,ModelsMap> postProcessAllModels(Map<String,ModelsMap> objs)
Post-processes all models to add C++ specific configurations and namespace handling. This method: - Computes model namespaces based on class names - Filters imports to exclude primitives and standard types - Processes model variables for proper C++ typing - Sets up proper getter/setter configurations- Specified by:
postProcessAllModelsin interfaceCodegenConfig- Overrides:
postProcessAllModelsin classAbstractCppCodegen- Parameters:
objs- map of all models to process- Returns:
- the processed models map
-
toModelName
public String toModelName(String name)
Converts an OpenAPI model name to a C++ class name. Handles inline model prefixes and converts to PascalCase.- Specified by:
toModelNamein interfaceCodegenConfig- Overrides:
toModelNamein classAbstractCppCodegen- Parameters:
name- the original model name- Returns:
- the C++ class name
-
toApiName
public String toApiName(String name)
Converts an API name to a C++ API class name. Handles default naming and path-based names.- Specified by:
toApiNamein interfaceCodegenConfig- Overrides:
toApiNamein classAbstractCppCodegen- Parameters:
name- the original API name- Returns:
- the C++ API class name
-
toApiFilename
public String toApiFilename(String name)
Converts an API name to its corresponding filename.- Specified by:
toApiFilenamein interfaceCodegenConfig- Overrides:
toApiFilenamein classDefaultCodegen- Parameters:
name- the API name- Returns:
- the filename without extension
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegenOutput the language-specific type declaration of the property.- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Overrides:
getTypeDeclarationin classDefaultCodegen- Parameters:
p- property schema- Returns:
- a string presentation of the property type
-
fromModel
public CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenConvert OAS Model object to Codegen Model object.- Specified by:
fromModelin interfaceCodegenConfig- Overrides:
fromModelin classDefaultCodegen- Parameters:
name- the name of the modelschema- OAS Model object- Returns:
- Codegen Model object
-
postProcessModelProperty
public void postProcessModelProperty(CodegenModel model, CodegenProperty property)
- Specified by:
postProcessModelPropertyin interfaceCodegenConfig- Overrides:
postProcessModelPropertyin classDefaultCodegen
-
toDefaultValue
public String toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegenReturn 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.
- Overrides:
toDefaultValuein classDefaultCodegen- Parameters:
p- Property schema- Returns:
- string presentation of the default value of the property
-
modelFileFolder
public String modelFileFolder()
Returns the directory path for generated model files.- Specified by:
modelFileFolderin interfaceCodegenConfig- Overrides:
modelFileFolderin classDefaultCodegen- Returns:
- the model file directory path
-
apiFileFolder
public String apiFileFolder()
Returns the directory path for generated API files.- Specified by:
apiFileFolderin interfaceCodegenConfig- Overrides:
apiFileFolderin classDefaultCodegen- Returns:
- the API file directory path
-
addProjectOrDefaultName
public String addProjectOrDefaultName(String name, String defaultName)
Adds project name to a class name or returns default name if project name is not set.- Parameters:
name- the base namedefaultName- the default name to use if input is null/empty- Returns:
- the project-prefixed name or default name
-
toModelNamespace
public String toModelNamespace(String modelNamespace)
Converts a model namespace string to proper format.- Parameters:
modelNamespace- the namespace to convert- Returns:
- the formatted model namespace
-
toPascalCase
public String toPascalCase(String name)
Converts a string to PascalCase formatting with consistent handling. Handles hyphens, underscores, and camelCase boundaries. Used for class names, type names, and enum names.- Parameters:
name- the string to convert- Returns:
- the PascalCase formatted string
-
toCamelCase
public String toCamelCase(String name)
Converts a string to camelCase formatting. Used for variable names and method names.- Parameters:
name- the string to convert- Returns:
- the camelCase formatted string
-
camelize
public String camelize(String name, boolean lowercaseFirstLetter)
Converts a string to camelCase or PascalCase with proper case handling. Handles uppercase words like "POST" -> "Post" and "GET" -> "Get".- Parameters:
name- the string to convertlowercaseFirstLetter- whether to lowercase the first letter (camelCase)- Returns:
- the camelized string
-
toHandlerFunctionName
public String toHandlerFunctionName(String httpMethod, String path, Boolean prefix)
Generates a handler function name from HTTP method and path.- Parameters:
httpMethod- the HTTP method (GET, POST, etc.)path- the API path- Returns:
- the generated handler function name
-
toHandlerFunctionRequest
public String toHandlerFunctionRequest(String path, String method)
Generates a handler function request type from the API Path- Parameters:
path- the API path- Returns:
- the generated handler function request
-
toHandlerFunctionResponse
public String toHandlerFunctionResponse(String path, String method)
Generates a handler function response type from the API path.- Parameters:
path- the API path- Returns:
- the generated handler function response
-
processOpts
public void processOpts()
Processes command line options and additional properties. Sets up default values for project configuration.- Specified by:
processOptsin interfaceCodegenConfig- Overrides:
processOptsin classAbstractCppCodegen
-
postProcessParameter
public void postProcessParameter(CodegenParameter parameter)
Post-processes parameters to set up C++ specific configurations. Handles the required flag and parameter type conversions.- Specified by:
postProcessParameterin interfaceCodegenConfig- Overrides:
postProcessParameterin classDefaultCodegen- Parameters:
parameter- the parameter to process
-
postProcessSupportingFileData
public Map<String,Object> postProcessSupportingFileData(Map<String,Object> objs)
Post-processes supporting file data to conditionally add files based on API features. This is called after preprocessOpenAPI, so hasAuthMethods is properly set.- Specified by:
postProcessSupportingFileDatain interfaceCodegenConfig- Overrides:
postProcessSupportingFileDatain classDefaultCodegen- Parameters:
objs- the supporting file data- Returns:
- the processed supporting file data
-
-