Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

OpenAPITools/sbt-openapi-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Sbt plugin to support the OpenAPI generator project.

Usage

Add to yourproject/plugins.sbt:

For new versions (7.14.0 or later), please use

addSbtPugin("org.openapitools"%"sbt-openapi-generator_2.12_1.0"%"7.17.0")

Ref:https://central.sonatype.com/artifact/org.openapitools/sbt-openapi-generator_2.12_1.0

For old versions (e.g. 7.13.0), please use

addSbtPlugin("org.openapitools"%"sbt-openapi-generator"%"7.13.0")

Ref:https://central.sonatype.com/artifact/org.openapitools/sbt-openapi-generator

Configuration

Configuration based on project module is recommended way to separate specifications by modules.

You must define one of the settingsopenApiInputSpec oropenApiConfigFile to able run plugin to generate.

Settings will be picked up fromopenApiConfigFile first if defined and then will be overwritten with module specifiedsettings if provided

With the next example modulegenerated will be defined as:

lazyvalgenerated= project.in(file("generated"))  .settings(    openApiInputSpec:="openapi.yaml",    openApiConfigFile:="config.yaml"  )

There is a helpers to have boolean settings more readable. Instead ofSome(true) it possible to do next:

    openApiValidateSpec:=SettingDisabled,    openApiGenerateModelTests:=SettingEnabled,

Execution

To print all available languages use

sbt openApiGenerators

To run template generation process

sbt openApiGenerate

or per defined module

sbt generated/openApiGenerate

Settings

SettingTypeDescription
openApiGeneratorName *StringThe name of the generator which will handle codegen. (see "openApiGenerators" task)
Required. Can be provided asgeneratorName option ofopenApiConfigFile json config
openApiInputSpec *StringThe Open API 2.0/3.x specification location (file or url)
Required. Can be provided asinputSpec option ofopenApiConfigFile json config
openApiOutputDirStringThe output target directory into which code will be generated
openApiConfigFile **StringPath to json configuration file
This setting is required withgeneratorName andinputSpec settings provided if sbt settingsopenApiGeneratorName andopenApiInputSpec are absent
openApiAdditionalPropertiesMap[String, String]Sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value. You can also have multiple occurrences of this option
openApiGlobalPropertiesMap[String, String]Sets specified system properties
openApiVerboseOption[Boolean]The verbosity of generation
openApiValidateSpecOption[Boolean]Whether or not an input specification should be validated upon generation
openApiTemplateDirStringThe template directory holding a custom template
openApiAuthStringAdds authorization headers when fetching the OpenAPI definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values
openApiSkipOverwriteOption[Boolean]Specifies if the existing files should be overwritten during the generation
openApiPackageNameStringPackage for generated classes (where supported)
openApiApiPackageStringPackage for generated api classes
openApiModelPackageStringPackage for generated models
openApiModelNamePrefixStringPrefix that will be prepended to all model names
openApiModelNameSuffixStringSuffix that will be appended to all model names
openApiInstantiationTypesMap[String, String]Sets instantiation type mappings
openApiTypeMappingsMap[String, String]Sets mappings between OpenAPI spec types and generated code types
openApiServerVariablesMap[String, String]Sets server variable for server URL template substitution, in the format of name=value,name=value. You can also have multiple occurrences of this option
openApiLanguageSpecificPrimitivesList[String]Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double
openApiImportMappingsMap[String, String]Specifies mappings between a given class and the import that should be used for that class
openApiInvokerPackageStringRoot package for generated code
openApiGroupIdStringgroupId in generated pom.xml/build.sbt
openApiIdStringartifactId in generated pom.xml/build.sbt. This also becomes part of the generated library's filename
openApiLibraryStringlibrary template (sub-template)
openApiGitHostStringGit host, e.g. gitlab.com
openApiGitUserIdStringGit user ID, e.g. openapitools
openApiGitRepoIdStringGit repo ID, e.g. openapi-generator
openApiReleaseNoteStringRelease note, default to 'Minor update'
openApiHttpUserAgentStringHTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}}/{language}'
openApiReservedWordsMappingsMap[String, String]]("Specifies how a reserved name should be escaped to
openApiIgnoreFileOverrideStringSpecifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
openApiRemoveOperationIdPrefixOption[Boolean]Remove prefix of operationId, e.g. config_getId => getId
openApiApiFilesConstrainedToList[String]Defines which API-related files should be generated. This allows you to create a subset of generated files (or none at all)
openApiModelFilesConstrainedToList[String]Defines which model-related files should be generated. This allows you to create a subset of generated files (or none at all)
openApiSupportingFilesConstrainedToList[String]Defines which supporting files should be generated. This allows you to create a subset of generated files (or none at all
openApiGenerateModelTestsOption[Boolean]Specifies that model tests are to be generated
openApiGenerateModelDocumentationOption[Boolean]Defines whether or not model-relateddocumentation files should be generated
openApiGenerateApiTestsOption[Boolean]Specifies that api tests are to be generated
openApiGenerateApiDocumentationOption[Boolean]Defines whether or not api-relateddocumentation files should be generated
openApiWithXmlOption[Boolean]A special-case setting which configures some generators with XML support. In some cases, this forces json OR xml, so the default here is false
openApiLogToStderrOption[Boolean]To write all log messages (not just errors) to STDOUT
openApiEnablePostProcessFileOption[Boolean]Enable post-processing file using environment variables
openApiSkipValidateSpecOption[Boolean]To skip spec validation. When true, we will skip the default behavior of validating a spec before generation
openApiGenerateAliasAsModelOption[Boolean]Generate model implementation for aliases to map and array schemas
openApiGenerateMetadataOption[Boolean]Generate metadata files used by OpenAPI Generator. This includes.openapi-generator-ignore and any files within.openapi-generator.

Examples

Please seean sbt-test configuration for examples of using the plugin.Do not run those examples directly, please copy them to separate place first.

Contribution and Tests

Write plugin integration tests undersrc/sbt-test

Execute next command to run tests:

sbt scripted

More information about how to write and execute testsis here

Packages

No packages published

Contributors12

Languages


[8]ページ先頭

©2009-2025 Movatter.jp