java.md

May 2, 2024 · View on GitHub

METADATA

PropertyValueNotes
generator namejavapass this to the generate command after -g
generator stabilitySTABLE
generator typeCLIENT
generator languageJava
generator language version17
generator default templating enginehandlebars
helpMsgGenerates a Java client library

Features in this generator:
- v3.0.0 - v3.1.0 OpenAPI Specification support
- Very thorough documentation generated in the style of javadocs
- Input types constrained for a Schema in SomeSchema.validate
- validate method can accept arbitrary List/Map/null/int/long/double/float/String json data
- Immutable List output classes generated and returned by validate for List<?> input
- Immutable Map output classes generated and returned by validate for Map<?, ?> input
- Strictly typed list input can be instantiated in client code using generated ListBuilders
- Strictly typed map input can be instantiated in client code using generated MapBuilders
- Sequential map builders are generated ensuring that required properties are set before build is invoked. Looks like:
- new MapBuilder().requiredA("a").requiredB("b").build()
- new MapBuilder().requiredA("a").requiredB("b").optionalProp("c").additionalProperty("someAddProp", "d").build()
- Run time type checking and validation when
- validating schema payloads
- instantiating List output class (validation run)
- instantiating Map output class (validation run)
- Note: if needed, validation of json schema keywords can be deactivated via a SchemaConfiguration class
- Enums classes are generated and may be input into Schema.validate or the List/MapBuilder add/setter methods
- The Checker-Framework's NullnessChecker and @Nullable annotations are used in the java client
- ensuring that null pointer exceptions will not happen
- Invalid (in java) property names supported like class, 1var, hi-there etc in
- component schema names
- schema property names (a fallback setter is written in the MapBuilder)
- Generated interfaces are largely consistent with the python code
- Openapi spec inline schemas supported at any depth in any location
- Format support for: int32, int64, float, double, date, datetime, uuid
- Payload values are not coerced when validated, so a date/date-time value can pass other validations that describe the payload only as type string
- enum types are generated for enums of type string/integer/number/boolean/null
- String transmission of numbers supported with type: string, format: number

CONFIG OPTIONS

These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to configuration docs for more details.

OptionDescriptionValuesDefault
allowUnicodeIdentifiersboolean, toggles whether unicode identifiers are allowed in names or not, default is falsefalse
artifactDescriptionartifact description in generated pom.xmlOpenAPI Java
artifactUrlartifact URL in generated pom.xmlhttps://github.com/openapi-json-schema-tools/openapi-json-schema-generator
artifactVersionartifact version in generated pom.xml. This also becomes part of the generated library's filename1.0.0
buildToolthe build automation tool used in generated code
maven
Use maven
gradle
Use gradle
maven
developerEmaildeveloper email in generated pom.xmlteam@openapijsonschematools.org
developerNamedeveloper name in generated pom.xmlOpenAPI-Generator Contributors
developerOrganizationdeveloper organization in generated pom.xmlOpenAPITools.org
developerOrganizationUrldeveloper organization URL in generated pom.xmlhttp://openapijsonschematools.org
groupIdgroupId in generated pom.xmlorg.openapijsonschematools
invokerPackageroot package for generated codeorg.openapijsonschematools.client
licenseNameThe name of the licenseUnlicense
licenseUrlThe URL of the licensehttp://unlicense.org
parentArtifactIdparent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effectnull
parentGroupIdparent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effectnull
parentVersionparent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effectnull
scmConnectionSCM connection in generated pom.xmlscm:git:git@github.com:openapi-json-schema-tools/openapi-json-schema-generator.git
scmDeveloperConnectionSCM developer connection in generated pom.xmlscm:git:git@github.com:openapi-json-schema-tools/openapi-json-schema-generator.git
scmUrlSCM URL in generated pom.xmlhttps://github.com/openapi-json-schema-tools/openapi-json-schema-generator
snapshotVersionUses a SNAPSHOT version.
true
Use a SnapShot Version
false
Use a Release Version
null
sourceFoldersource folder for generated codesrc/main/java
testOutputSet output folder for models and APIs tests${project.build.directory}/generated-test-sources/openapi

SUPPORTED VENDOR EXTENSIONS

Extension nameDescriptionApplicable forDefault value
x-enum-varnamesA list of strings that defines the enum variable names, must be adjacent to enumSCHEMA[]
x-enum-descriptionsA list of strings that defines the enum descriptions, must be adjacent to enumSCHEMA[]

INSTANTIATION TYPES

Type/AliasInstantiated By
arrayFrozenList
booleanboolean
integerNumber (int, long, float with integer values, double with integer values)
nullVoid (null)
numberNumber (int, long, float, double)
objectFrozenMap
stringString

LANGUAGE PRIMITIVES

  • Boolean
  • Double
  • Float
  • Integer
  • Long
  • Object
  • String
  • boolean
  • byte[]

RESERVED WORDS

  • abstract
  • apiclient
  • apiexception
  • apiresponse
  • assert
  • boolean
  • break
  • byte
  • case
  • catch
  • char
  • class
  • configuration
  • const
  • continue
  • default
  • do
  • double
  • else
  • enum
  • extends
  • final
  • finally
  • float
  • for
  • goto
  • if
  • implements
  • import
  • instanceof
  • int
  • integer
  • interface
  • linkedhashset
  • list
  • localdate
  • localreturntype
  • localvaraccept
  • localvaraccepts
  • localvarauthnames
  • localvarcollectionqueryparams
  • localvarcontenttype
  • localvarcontenttypes
  • localvarcookieparams
  • localvarformparams
  • localvarheaderparams
  • localvarpath
  • localvarpostbody
  • localvarqueryparams
  • long
  • map
  • native
  • new
  • null
  • number
  • package
  • private
  • protected
  • public
  • return
  • short
  • static
  • strictfp
  • string
  • stringutil
  • super
  • switch
  • synchronized
  • this
  • throw
  • throws
  • tostring
  • transient
  • try
  • uuid
  • void
  • volatile
  • while
  • zoneddatetime

FEATURE SET

Client Modification Feature

NameSupportedDefined By
BasePathToolingExtension
AuthorizationsToolingExtension
UserAgentToolingExtension
MockServerToolingExtension

Components Feature

NameSupportedDefined By
schemasOAS3
responsesOAS3
parametersOAS3
examplesOAS3
requestBodiesOAS3
headersOAS3
securitySchemesOAS3
linksOAS3
callbacksOAS3
pathItemsOAS3

Data Type Feature

NameSupportedDefined By
CustomOAS2,OAS3
Int32OAS2,OAS3
Int64OAS2,OAS3
IntegerOAS2,OAS3
FloatOAS2,OAS3
DoubleOAS2,OAS3
NumberOAS2,OAS3
StringOAS2,OAS3
ByteOAS2,OAS3
BinaryOAS2,OAS3
BooleanOAS2,OAS3
DateOAS2,OAS3
DateTimeOAS2,OAS3
PasswordOAS2,OAS3
FileOAS2
UuidOAS2,OAS3
ArrayOAS2,OAS3
NullOAS3
AnyTypeOAS2,OAS3
ObjectOAS2,OAS3
EnumOAS2,OAS3

Documentation Feature

NameSupportedDefined By
ReadmeToolingExtension
ServersOAS3
SecurityOAS2,OAS3
ComponentSchemasOAS3
ComponentResponsesOAS3
ComponentParametersOAS3
ComponentRequestBodiesOAS3
ComponentHeadersOAS3
ComponentSecuritySchemesOAS3
ComponentLinksOAS3
ComponentCallbacksOAS3
ComponentPathItemsOAS3
ApiToolingExtension

Global Feature

NameSupportedDefined By
InfoOAS2,OAS3
ServersOAS3
PathsOAS2,OAS3
WebhooksOAS3
ComponentsOAS3
SecurityOAS2,OAS3
TagsOAS2,OAS3
ExternalDocsOAS2,OAS3

Operation Feature

NameSupportedDefined By
Responses_HttpStatusCodeOAS3
Responses_RangedResponseCodesOAS3
Responses_DefaultOAS3
Responses_RedirectionResponseOAS3
SecurityOAS2,OAS3
ServersOAS3

Parameter Feature

NameSupportedDefined By
NameOAS2,OAS3
RequiredOAS2,OAS3
In_PathOAS2,OAS3
In_QueryOAS2,OAS3
In_HeaderOAS2,OAS3
In_CookieOAS3
Style_MatrixOAS3
Style_LabelOAS3
Style_FormOAS3
Style_SimpleOAS3
Style_SpaceDelimitedOAS3
Style_PipeDelimitedOAS3
Style_DeepObjectOAS3
ExplodeOAS3
SchemaOAS3
ContentOAS3

Schema Feature

NameSupportedDefined By
AdditionalPropertiesOAS2,OAS3
AllOfOAS2,OAS3
AnyOfOAS3
ConstOAS3
ContainsOAS3
DefaultOAS2,OAS3
DependentRequiredOAS3
DependentSchemasOAS3
DiscriminatorOAS2,OAS3
ElseOAS3
EnumOAS2,OAS3
ExclusiveMinimumOAS2,OAS3
ExclusiveMaximumOAS2,OAS3
FormatOAS2,OAS3
IfOAS3
ItemsOAS2,OAS3
MaxContainsOAS3
MaxItemsOAS2,OAS3
MaxLengthOAS2,OAS3
MaxPropertiesOAS2,OAS3
MaximumOAS2,OAS3
MinContainsOAS3
MinItemsOAS2,OAS3
MinLengthOAS2,OAS3
MinPropertiesOAS2,OAS3
MinimumOAS2,OAS3
MultipleOfOAS2,OAS3
NotOAS3
NullableOAS3
OneOfOAS3
PatternOAS2,OAS3
PatternPropertiesOAS3
PrefixItemsOAS3
PropertiesOAS2,OAS3
PropertyNamesOAS3
RefOAS2,OAS3
RequiredOAS2,OAS3
ThenOAS3
TypeOAS2,OAS3
UnevaluatedItemsOAS3
UnevaluatedPropertiesOAS3
UniqueItemsOAS2,OAS3
XmlOAS2,OAS3

Security Feature

NameSupportedDefined By
HTTP_BasicOAS2,OAS3
ApiKeyOAS2,OAS3
OpenIDConnectOAS3
HTTP_BearerOAS2,OAS3
OAuth2_ImplicitOAS2,OAS3
OAuth2_PasswordOAS2,OAS3
OAuth2_ClientCredentialsOAS2,OAS3
OAuth2_AuthorizationCodeOAS2,OAS3

Wire Format Feature

NameSupportedDefined By
JSONOAS2,OAS3
XMLOAS2,OAS3
PROTOBUFToolingExtension
CustomOAS2,OAS3