Skip to content
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

JsonSchema - Enum - description / open-endness #1281

Open
larslarsson opened this issue Nov 12, 2020 · 2 comments
Open

JsonSchema - Enum - description / open-endness #1281

larslarsson opened this issue Nov 12, 2020 · 2 comments

Comments

@larslarsson
Copy link

larslarsson commented Nov 12, 2020

How to add description in a json schema the best way? According to standard & be able to generate code - this code & generally/others

https://github.com/RicoSuter/NJsonSchema/wiki/Enums
https://groups.google.com/forum/#!topic/json-schema/w_5mVYB7OHg
json-schema-org/json-schema-spec#57

Is it possible to setup the schema to automatically support additions to enum - Json schema not OpenApi.
https://www.gitmemory.com/issue/RicoSuter/NJsonSchema/1159/624497529
How? Example - generall support? Admitting not running latest version during simple test & some modification to generate file per file. The linked case for OpenApi is still opened & this is open-api specific then? Caught my eye & seemed nice/cool.

Can you have enum as string but still control the integer value of generated code?

@RicoSuter
Copy link
Owner

In general with JSON Schema/OpenAPI you can only describe the values so for integer enums you cannot describe the enum name only the enum value... That's why we introduced "x-enum-names" with which you can describe the name of each value... but this is only generated by NJS and also only picked up by NJS for code generation.

What do you propose to add to this?

@larslarsson
Copy link
Author

larslarsson commented Nov 12, 2020

Integration/external contract - so first was if I can describe the enum since it changes other objects values or interpetation. Secondly so far only documentation say handling of enum changes, would be nice to have in json (could use int/string and document instead but decreases readability) - i.e. newtonsoft can inject and handle enum & make default/unkown for missmatch. Thirdly realized if I can internally control int value I could be lazy and cast instead of correctly convering, even thou I would obviously not take such shortcut...

Using schema for generating code/documenting structure rather then validation it is designed for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants