-
Notifications
You must be signed in to change notification settings - Fork 80
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
Rewrite ExampleJsonGenerator #368
Comments
Hi @timonback , can I work on this? |
Sure, @Sakshi-75 . Go ahead. If you have any questions, feel free to discuss here or join us on Discord |
Hi @timonback ,
|
The sorted keys are new, so I am open to go back to the previous behaviour (properties are ordered by appearance). I guess that is also a matter of how the ObjectMapper is configured (same with your second question). tldr: Yes, to both if avoiding it is too much of a hassle |
Hi @timonback , I tried to add the spaces manually as well but that was not working properly in case of composite objects. Is it okay if I go ahead without adding the spaces or should I use the pretty printer version? |
Let's take the simple route and we go from there :) |
Hi @timonback , |
Hi @Sakshi-75 In a later stage, we hope to support the allOf property of the schema annotation, which currently (wrongly) behaves like the oneOf property. We imagine that the rewrite of the class will help to resolve this issue - besides the error prone string concatenations. Are you up to continue the rewrite to ObjectNode/etc for the internal methods of the class as well? Feel free to continue on the branch. If you prefer, we can also merge it at this point. Whatever you prefer. |
Hi @timonback , |
Hello @timonback , I would like to work on this issue if it's still available. |
Hi @dipeshsingh253 I merged @Sakshi-75 code, so you can use on her contributions. |
Hi @timonback , Thanks for your quick response. I am unsure where to start on this issue, so if you can share the file or module then it will be faster for me. |
Hi @dipeshsingh253, The goal is the following:
This is a pure technical refactoring so that we avoid passing around strings and concatenating them together. Instead, we let Jackson (via |
Hello @timonback , I have successfully completed the setup, and I greatly appreciate your assistance with it. In addition, I've made some adjustments to the ExampleJsonGenerator.java file, which you can find here: link. However, I've encountered an issue: Previously, for string schemas(most of the datatypes like string, boolean), we were returning "string" directly. But now, in internal methods, we need to return an ObjectNode. Unfortunately, this results in an output like {"string":"string"}. I've attempted to find a solution for creating an ObjectNode without a key, but none of the solutions I found online seem to work. I would greatly appreciate your guidance on whether I am on the right path or if there's an alternative approach I should consider. Thanks once again, @timonback! Working on this issue is an exciting opportunity for me to contribute to open source! |
As these are internal methods, you are free to refactor/change them as you need - including their return type - as long as the tests are passing at the end. I had a look at the docs, it seems there is a TextNode to represent a string: |
We can also start small. Feel free to open a draft PR and then we go from there. PRs are easier to review for us, as they only show the actual changes and we can run the tests on them. Happy to assist |
Hi @dipeshsingh253 , thanks a lot for your contribution. Overall your change looks good, but there are some minor changes we would like to see. See my comments in the PR. |
Hi @timonback @sam0r040 , I think we can close this issue now. |
The final refactoring was released. Thank you for the contributions! |
Describe the feature request
Instead of using the manual approach (basically StringBuilder), we should use a library like jackson (using
JsonNode
and similar objects) to build the example payload as a tree and the convert it to string at the end.Motivation
When we removed
swagger-inflector
, we started with a very manual approach to create an example json object from an asyncapi schema.This approach has some short-comings.
Technical details
The class in question: https://github.com/springwolf/springwolf-core/blob/master/springwolf-core/src/main/java/io/github/stavshamir/springwolf/schemas/example/ExampleJsonGenerator.java
It does have decent test coverage already, although test can always be added.
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: