swagger-api / swagger-api/swagger-parser

Customize local ref loading and block remote ref loading

Open
#1,425 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

I am trying to reference a local file Money.json in another schema provisions.json using $ref as mentioned below:

provisions.json

"responses": { "200": { "schema": { "$ref": "resources/json/Money.json#/definitions/Money" },

resources/json/Money.json

"definitions": { "Money": { "type": "object", "properties": { "amount": { "type": "number", "format": "bigdecimal", "description": "Amount" }, "currency": { "type": "string", "description": "A unique internal identifier for the currency" } } }

I want to customize the resource loading behaviour as per my requirement. For example I want to restrict the loading of remote URLs and allow local refs or interpret the ref URLs as per my application requirements. Is it possible to maybe register my custom reference resolver and loader.
As per the documentation I could not find any such capability in the parser.

Originally posted by @apurvaSAP in https://github.com/swagger-api/swagger-parser/issues/1074#issuecomment-692560830

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the parser documentation for reference loading, then use the provisions.json and resources/json/Money.json examples to trace how the local $ref is handled. Define the resolver or loader customization needed to interpret application-specific references and reject remote URLs; done means local references work while remote loading is blocked.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.