swagger-api / swagger-api/swagger-parser
Customize local ref loading and block remote ref loading
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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