-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 YAML syntax for JSON Schema #778
Comments
Hi. It would be really simple to convert the YAML to json before sending it to jsonschema2pojo. Check out e.g. https://github.com/wildducktheories/y2j |
You are right. But the trick is to specify my model in YAML with JSON Schema syntax and then generate the POJOs in one single step using Maven. Using your cool tool, I am able to take JSON Schemas (in JSON) and generate the POJOs using the Maven plugin in one step. |
It's a shame Maven makes adding extra ad-hoc steps like this so annoying to do. I don't see any problem in adding |
Are you actually planning to bind YAML data to your types, or are you using YAML to represent JSON Schema... to specify JSON data? The good news is that I think Jackson's YAML support would be compatible with all the Jackson annotations that we're currently generating. |
I am considering to use YAML instead of JSON to represent JSON Schemas (easier to read). I use JSON Schema for defining all classes/entities/objects in my domain model. So when I need concrete Java objects (POJOs), I just generate these based on the JSON Schemas (YAML or JSON). I love Jackson. So I really appreciate the addition of the YAML support to Jackson. 👍 |
It reminds me of Swagger/Open API, where it is possible to define and document a REST specification in either YAML or JSON. I believe that some schema (JSON Schema?) is being used for defining the Swagger/OpenAPI format. |
I'm implementing this for the next release (0.5.0). You'll be able to choose a source type of 'yaml' (example yaml that you need to bind) or yamlschema (a JSON Schema represented as YAML). I think using these to generate types then Jackson's YAML support for actual data binding works nicely. |
Thanks again for raising this btw, I think a lot of people will find this useful. |
That is really great news! I am sure a lot of people will appreciate this feature. :-) As soon as you want it tested, don't hesitate with writing back and I will change the JSON stuff into YAML to see how it goes. :-) |
I had something like this in my mind but I see there is a drive going on to support YAML. Will be waiting for the feature. |
@clipod it is implemented and released already. |
@joelittlejohn Thanks. I will test it out. |
do you guys have using YAML to present JSON schema sample guide? |
I really love the jsonschema2pojo tool. :-)
It would be even greater, if you add support for YAML which uses the JSON Schema for defining Java POJOs.
So instead of using JSON for defining a "BotState" (in JSON Schema for format) with bot-state.json:
... I can use YAML instead (bot-state.yaml):
The text was updated successfully, but these errors were encountered: