Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

networknt schema validator, get schema with $ref resolved

I am using json schema for defining and validating rest api input payloads using networknt schema validator. Internally i have defined schemas and put all the common def in common schema and added local resource $ref to these defs whenever needed. Now these schemas will be used by users to send proper payloads and i have defined get schema apis to return these schemas. However when i get the schemas from netorknt schema validator it comes as its defined with $ref as is. This is very inconvenient to users to retrieve multiple schemas and manually look at the defs in common schema to see how its defined. I wanted to check if there is any way networknt schema validato provides any way to retrieve schemas with $ref resolved with the actual defs instead of $refs.

I am trying to avoid writing my own parser to resolve these $ref and replace with actual defs.

like image 682
palwe-prafulla Avatar asked Sep 04 '26 09:09

palwe-prafulla


1 Answers

When running within the OpenAPI specification context, it only resolves the local references in the same file. Remote references should be handled in the openapi-bundler(https://github.com/networknt/openapi-bundler) as most servers don't have access to the Internet at all. And downloading schemas from the Internet during the runtime is risky.

like image 188
Steve Hu Avatar answered Sep 10 '26 06:09

Steve Hu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!