palwe-prafulla
palwe-prafulla

Reputation: 141

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.

Upvotes: 3

Views: 826

Answers (1)

Steve Hu
Steve Hu

Reputation: 388

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.

Upvotes: 1

Related Questions