Question: How to get plain JSON schema without example?
Closed this issue · 3 comments
Library version used
"0.5.0"
Language library used with
Java
Describe the issue
Is there a way to get JSON Schema from RAML/OAS without the example added to it after parsing?
Right now, I am using toJsonSchema(), it gives a JSON schema with the example appended to the schema.
'''
NodeShape schema = (NodeShape) api
.endPoints().get(0)
.operations().get(0)
.responses().get(0)
.payloads().get(0)
.schema();
String json = schema.toJsonSchema();
'''
This json string contains the schema + the example specified in the file. I want only the schema.
Thanks!
Hi @namitrk97. You could use this method to override examples array with an empty array:
E.g.
...
.payloads().get(0)
.withExamples(<empty_array_here>)
.schema();
// Continue as usual
PS. I can't tell what exact Java type <empty_array_here>
should be. Try List, Array or something else.
Closing for now. Feel free to reopen if you still have questions.