swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

Permit accessing "extra" structures and fields left over after OpenAPIDeserializer parses everything

Open blast-hardcheese opened this issue 4 years ago • 2 comments

So, as always, thank you for your work maintaining swagger-parser, it has made my task writing and maintaining guardrail orders of magnitude easier.

One challenge I've experienced recently is how to effectively communicate to the user when they've used an OpenAPI 2.x structure in a 3.x document.

To this end, I'd like to modify OpenAPIDeserializer to copy() the JsonNode rootNode at the beginning of deserialize, and as it successfully consumes fields (via the get* functions), it removes them from the tree, maintaining a reference, and if the structure (in my case, primarily thinking about ObjectNode) is not empty, attaching that as a new field on each of the associated swagger-models.

This represents a fairly significant deviation from how the current parser works, but I think it would permit all consumers of swagger-parser to produce much more helpful error messages, guiding users to why their specification is not working as they intend.

I'd appreciate some feedback on this idea (has it been tried before? Does it already exist in the repo, possibly a strict validation extension to the underlying parser, and I've just missed it somehow?)

Thank you for the consideration, I'd be more than happy to attempt to implement it if this seems reasonable.

blast-hardcheese avatar Apr 30 '20 23:04 blast-hardcheese

Hi @blast-hardcheese thanks for your feedback, can you please write a minimal sample, with an input spec, and a expected result with the approach you are suggesting. Thanks!

gracekarina avatar May 01 '20 17:05 gracekarina

This has been open for a while, I don't know when I'll be able to return to it, but I'm still interested in this. Just checking in.

blast-hardcheese avatar Sep 22 '20 08:09 blast-hardcheese