-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support more metadata in SwaggerConf #53
Support more metadata in SwaggerConf #53
Conversation
Seems that there's yet another non-determinism issue:
or sometimes:
Don't know what could be the cause, though... |
Thanks for the contribution. I’ll take a look as soon as possible. |
Thanks! So, I've done some investigation and I have an hypothesis: the ObjectMapper serializes the ServerVariable object non-deterministically because there's no annotations on the proper serialization order. However, if that hypothesis is correct, I'd expect we'd have had this particular problem a lot earlier for other classes, because ServerVariable is just a POJO. Because I cannot modify ServerVariable (as it's part of the swagger core library), we'd have to work around it. I see the following options:
Both options seem unappealing to me, so I hope I'm wrong (or that there is yet another alternative). I will await your guidance on this matter. |
@langecode Would you have the time to review/collaborate on this PR soon :-) ? |
Yeah. Just have been staring up on a new job. It seems it is only non-deterministic on Java 8? Or at least I cannot provoke the error running the test on higher VM versions? But I have checked out the PR and will go through it. |
So finally I had a bit of time looking through this - sorry for the wait. I see your point with the need to re-model the OpenAPI domain model. I think originally we did this to ease the migration from the kongchen plugin - as we were using that but running into some problems. For now I like your approach - may yield a bit more information in the Maven output in case of failure. But it could be worth considering another approach in a new major version. For the concrete problem, I have a theory however I am not sure. If I remember correctly Jackson uses the Java Bean API to discover properties of the POJOs. Looking at the error from the test and the other serializations that do not fail I have a hypothesis. The only thing standing out with the I started out doing a more semantic validation of the output - however it seems many commit the output into Git and want a deterministic output. But as you, I haven't any really good solution to this. I would lean towards a fix for just |
Closed by #58 |
For our project, we need the swagger-maven-plugin to emit
securityScheme
(undercomponents
) and we want to useserver
URL variables. The OpenAPI spec supports those, but the swagger-maven-plugin doesn't implement those. This PR adds support for those data fields and objects. Additionally, it adds comments where there weren't any.Note: this is still incomplete, because
components
has many more (useful) things to specify, likeexamples
. However, I think this PR is satisfactory for now and in line with the existing codebase.Alternative idea
I do think an alternative architecture could be considered: I think the
<swaggerConfig>
field could just be raw OpenAPI 3.0 YAML/JSON (or a syntactic XML-equivalent). Instead of re-modelling every OpenAPI construct in Java, the plugin could just parse the raw OpenAPI spec "template" and use it as basis for further modification. I think CDATA or simply referring to an actual YAML/JSON "template" file should work. I do hope this approach would still allow Maven variable substitution (e.g., to inject version numbers compile-time). Opinion?