You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
specifying explicitely additionalProperties: true was required to let generated Java classes support additional properties not specified in the Swagger file (untested on openapi-generator)
even with this specified, the generated code didn't work properly
when generating fat swagger, creates top level types for inlined (non-Venetian-blind) types. It shouldn't. The generated types don't follow styleguide naming convention. (untested on openapi-generator)
generated code's formatting a bit better
invalid escaping for regexp: @Pattern(regexp="\d{11}") => doesn't compile, should be @Pattern(regexp="\\d{11}") (tested with v3 of codegen)
openapi-generator:
more actively developed
unnecessary java imports, bad formatting in generated code - maybe fixable with some tuning
additionalProperties: true has no effect
4.x use of allOf:
generate useless *AllOf classes for Swagger types inlined in an allOf composition. They are imported in the composite class but not used
workaround for both: only specify base class in allOf and specify properties on same level like this: MyType: { allOf: [$ref: '#/components/schemas/T'], properties: { x: {type: string}} }
converts format: uri to java.net.URI as of 4.1.0
In 4.3.1: inline object types become java.lang.Object instead of proper generated type. Workaround: make them explicit (non-inline) types
Other notes:
specifying an array of types, while valid JSON Schema, doesn't seem to be supported in OpenAPI
format: decimal isn't part of the OpenAPI standards, and isn't supported for code generation
Custom typemappings may be needed in maven config, e.g.
to get byte array as return type (e.g. when returning image) for type: file instead of default java.io.File: <typeMappings><typeMapping>file=byte[]</typeMapping></typeMappings>
all plugins: JAX-RS always returns a default http status code (200 for OK with body, 204 for OK without body). Only way to override is by generating javax.ws.rs.core.Response return types for all generated models.
Smals will share their extensions to the code generation plugin, adding proper support for additional properties to all generated classes.
In GitLab by @pvdbosch on Sep 7, 2018, 16:25
Test senya.io, stoplight.io, apicurio or any other interesting tool to author swagger files.
Evaluate code generation maven plugins: openapi-generator vs swagger codegen.
Recommend one?
Comparison (WIP):
Swagger codegen:
additionalProperties: truewas required to let generated Java classes support additional properties not specified in the Swagger file (untested on openapi-generator)@Pattern(regexp="\d{11}")=> doesn't compile, should be@Pattern(regexp="\\d{11}")(tested with v3 of codegen)openapi-generator:
additionalProperties: truehas no effectallOfcomposition. They are imported in the composite class but not usedallOfwith a referenced type: e.g. InvalidParamProblem no longer extends Problem (see [BUG] [Java] inheritance is generated without discriminator field OpenAPITools/openapi-generator#5097 (comment))MyType: { allOf: [$ref: '#/components/schemas/T'], properties: { x: {type: string}} }format: urito java.net.URI as of 4.1.0Other notes:
format: decimalisn't part of the OpenAPI standards, and isn't supported for code generationtype: fileinstead of default java.io.File:<typeMappings><typeMapping>file=byte[]</typeMapping></typeMappings>javax.ws.rs.core.Responsereturn types for all generated models.