-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluate OpenAPI tooling #25
Comments
In GitLab by @pvdbosch on Oct 5, 2018, 12:01 Most authoring tools seem to have difficulties with definitions referenced from external YAML files. Some feedback from our developers:
RepreZen is another paying alternative, but didn't try out yet. |
In GitLab by @pvdbosch on Nov 23, 2018, 16:21 Latest 0.20 version of Senya works fine now. Tested with socialStatus API, with external files, both in text as UI mode. I reported the bug concerning examples (as mentioned in #28) in Swagger and it got fixed. |
In GitLab by @pvdbosch on Dec 17, 2018, 11:54 KaiZen as eclipse plugin SwaggerUI watcher https://github.com/moon0326/swagger-ui-watcher views in browser can be added to list of tools in style guide |
In GitLab by @wsalembi on Jan 20, 2019, 12:09 Senya Editor for Intellij IDEA has become a paid plugin for https://senya.io/release-notes-1-0-0/ (48 euro/year) |
In GitLab by @pvdbosch on Jan 22, 2019, 10:15 updated the styleguide:
|
In GitLab by @pvdbosch on Jan 22, 2019, 11:53 changed title from evaluate {-tools to author swagger files-} to evaluate {+swagger tooling+} |
In GitLab by @pvdbosch on Jan 22, 2019, 12:11 Broadening scope of the issue to also include other tooling, like codegen. For code generation from swagger, there are two plugins:
Both still seem under active development, though openapi-generator seems to have more activity. Some issues encountered by @VirginieHayot when using the swagger codegen:
Smals (@smals-wisa ) developed an extension to the plugin, adding proper support for additional properties to all generated classes. It would be interesting to other WG members if this extension could be shared. |
In GitLab by @pvdbosch on Feb 26, 2019, 13:50 Added WIP comparison between codegen plugin to issue description, everyone can contribute. |
In GitLab by @pvdbosch on Feb 26, 2019, 13:50 changed the description |
In GitLab by @pvdbosch on Feb 27, 2019, 12:14 changed the description |
In GitLab by @pvdbosch on Feb 27, 2019, 12:17 Another codegen issue encountered with InvalidParamProblem; arrays of types cause property to be ignored during code generation:
(from new problem-v1.yaml) |
In GitLab by @pvdbosch on Mar 11, 2019, 09:50 Omitting Having no |
In GitLab by @pvdbosch on Mar 11, 2019, 10:05 changed the description |
In GitLab by @pvdbosch on Mar 11, 2019, 10:08 added some more remarks on codegen plugin, after some testing. The openapi-generator generates some weird warnings, but they can be ignored it seems.
For the |
In GitLab by @pvdbosch on Jun 20, 2019, 09:39 changed the description |
In GitLab by @ehealth-eh053 on Jun 24, 2019, 11:09
When using the openapi-generator-maven-plugin the generated source doesn't use the correct code for the default errors.
|
In GitLab by @jimmy.praet on Jul 15, 2019, 11:56 I have some issues with the openapi-generator-maven-plugin (3.3.4):
This generates the following:
The I tried configuring a default in the swagger file, but this didn't make any difference. |
In GitLab by @pvdbosch on Aug 8, 2019, 12:22 Another pitfall encountered with generated code is that JAX-RS always returns a default http status code (200 for OK with body, 204 for OK without body). The status codes in the Swagger To allow for other response codes, you can configure |
In GitLab by @pvdbosch on Aug 23, 2019, 11:13 changed the description |
In GitLab by @pvdbosch on Aug 23, 2019, 11:15 changed the description |
In GitLab by @pvdbosch on Aug 23, 2019, 11:15 Some results of tests with openapi generator 4.1.0 added to issue description:
|
In GitLab by @pvdbosch on Aug 23, 2019, 12:12 changed the description |
My findings on the inheritance vs composition issue in comment #25 (comment) : For a "oneOf", the discriminator makes sense, to know which object you receive. But just to have some abstract superclass (or better, an interface) for some classes, it doesn't make sense. The generated classes now all have the chosen discriminator property (e.g. "classType"), but the value is not coded in the generated classes although it should be possible (it's just the name of the class, right?). They are however generated on the server (by the jax-rs impl.?). But I don't like that, it's not clean to have such a type property in the returned JSON. On another note, with openapi-generator-maven-plugin 5.4.0, the plugin configuration below generates invalid classes:
You need to use this instead:
|
A PR OpenAPITools/openapi-generator#14172 has been merged in openapi-generator that supports configuration of a REF_AS_PARENT_IN_ALLOF "normalizer", which should enable use of inheritance. |
@jpraet, that's interesting! We can check how to best apply this (mainly to Problem types). From what I can see, we'll be able to choose between:
|
Another observation with openapi-generator-maven-plugin: when using an enum as a query param, only UPPER_CASE values are accepted at runtime. This is fixed in 6.x: OpenAPITools/openapi-generator#7494 |
openapi-generator-maven-plugin 6.3.0 is released. Using allOf refs as parent can be enabled globally by adding Alternatively, "x-parent: true" can be added to the schema objects to be used as parent class. |
PR #123 makes some changes to list of OpenAPI tooling: |
In the latest openapi-generator versions 6.5.0 and 6.6.0, this no longer generates inheritance, even with But with
it works. |
I've reported an issue for the openapi-generator-maven-plugin regression mentioned above: OpenAPITools/openapi-generator#16389 |
New version 7.0.0 of the openapi-generator seems to work fine:
We could add |
IntelliJ Ultimate 2023.2 switched the OpenAPI preview from SwaggerUI to redocly. It has a couple UX regressions IMO: overview of all operations is less at-a-glance, and schemas aren't listed separately from the operations. |
From my testing and with the feedback I got from OpenAPITools/openapi-generator#16389, you'll need to set S:
allOf:
- $ref: '#/components/schemas/T'
type: object
properties:
x:
type: string
y:
type: string |
There's a button to switch to SwaggerUI, bit it unfortunately keeps opening the preview in Redocly by default. Redocly also crashes on this: /health:
$ref: cbss/common/v1/common-v1.yaml#/paths/~1health I think because of Redocly/redoc#2337 Other sidenote: I also get "Unresolved reference" errors now in the openapi editor since the last IntelliJ IDE upgrade. default:
$ref: belgif/problem/v1/problem-v1.yaml#/components/responses/ProblemResponse It's happy when I add quotes default:
$ref: "belgif/problem/v1/problem-v1.yaml#/components/responses/ProblemResponse" |
Works for me without REFACTOR_ALLOF_WITH_PROPERTIES_ONLY, but I'd have to create a vanilla project and compare it with your configuration to make sure.
Thanks, hadn't seen that. |
As of openapi-generator 6.5, optional array properties no longer get initialized with an empty list (OpenAPITools/openapi-generator#15891). From the ticket, it seems unsure whether that change in behavior is either intentional, or a regression. While we don't want implementation quirks in tooling inform our decisions on API guidelines, it does raise the question for me whether we should spend more thought on making array properties required vs optional. For example: the items property of collection resources.
So shouldn't the items property be marked required then in the example openapi spec? rest-guide/guide/src/main/asciidoc/resources-collection.adoc Lines 88 to 98 in 66606c8
|
I agree, I don't see any use case in which "items" array shouldn't present in a collection. I think the new behavior of the openapi-generator is consistent; other types are also initialized as null when the property is absent. We also consider null and absent JSON properties as equivalent, while an empty array is different.
|
some more openapi-generator 7.0 findings:
|
Yes |
As of 2023.2.2, IntelliJ remembers your choice of preview tool. |
In v7.0.0, model classes have a new constructor with required properties. If this constructor is a single arg, Spring boot/Jackson applies a mapping so that fields with the
|
to investigate: differences between typeMappings/schemaMappings/importMappings in openapi-generator |
I've created a couple GitHub Discussions to replace this issue, in order to keep the issue backlog clean and the discussions more focused: Please continue to exchange your ideas and experiences in these discussions. |
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: true
was 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: true
has no effectallOf
composition. They are imported in the composite class but not usedallOf
with 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: uri
to java.net.URI as of 4.1.0Other notes:
format: decimal
isn't part of the OpenAPI standards, and isn't supported for code generationtype: file
instead of default java.io.File:<typeMappings><typeMapping>file=byte[]</typeMapping></typeMappings>
javax.ws.rs.core.Response
return types for all generated models.The text was updated successfully, but these errors were encountered: