Skip to content

Commit

Permalink
feat(reference): add support for switching external resolution on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n committed Dec 29, 2020
1 parent 4aa9309 commit 16d5696
Show file tree
Hide file tree
Showing 9 changed files with 647 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ const ReferenceObjectsResolveStrategy: stampit.Stamp<IResolveStrategy> = stampit
// manually add root reference
refSet.add(rootReference);

// nothing to resolve, so exit early
if (!options.resolve.external) {
return refSet;
}

// resolve all found Reference Object elements
for (const externalReferenceObject of externalReferenceObjects) {
// eslint-disable-next-line no-await-in-loop
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"prop": {
"$ref": "ex2.json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"prop": {
"$ref": "ex3.json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prop": "value"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"openapi": "3.1.0",
"x-top-level": "value",
"info": {
"title": "Sample API",
"description": "Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.",
"summary": "example summary",
"termsOfService": "Terms of service",
"version": "0.1.9",
"x-version": "0.1.9-beta",
"license": {
"name": "Apache License 2.0",
"x-fullName": "Apache License 2.0",
"identifier": "Apache License 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0"
},
"contact": {
"name": "Vladimir Gorej",
"x-username": "char0n",
"url": "https://www.linkedin.com/in/vladimirgorej/",
"email": "[email protected]"
}
},
"paths": {
"/users": {
"summary": "path item summary",
"description": "path item description",
"get": {
"tags": ["tag1", "tag2"],
"summary": "Returns a list of users.",
"description": "Optional extended description in CommonMark or HTML.",
"externalDocs": {
"description": "Find more info here",
"url": "https://example.com"
},
"operationId": "getUserList",
"parameters": [
{
"$ref": "ex1.json"
}
],
"requestBody": {
"content": {}
},
"responses": {
"200": {
"description": "A JSON array of user names",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"201": {
"description": "A response"
}
}
},
"parameters": [
{
"name": "userId",
"in": "query",
"description": "ID of the user",
"required": true
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"openapi": "3.1.0",
"x-top-level": "value",
"info": {
"title": "Sample API",
"description": "Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.",
"summary": "example summary",
"termsOfService": "Terms of service",
"version": "0.1.9",
"x-version": "0.1.9-beta",
"license": {
"name": "Apache License 2.0",
"x-fullName": "Apache License 2.0",
"identifier": "Apache License 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0"
},
"contact": {
"name": "Vladimir Gorej",
"x-username": "char0n",
"url": "https://www.linkedin.com/in/vladimirgorej/",
"email": "[email protected]"
}
},
"paths": {
"/users": {
"summary": "path item summary",
"description": "path item description",
"get": {
"tags": ["tag1", "tag2"],
"summary": "Returns a list of users.",
"description": "Optional extended description in CommonMark or HTML.",
"externalDocs": {
"description": "Find more info here",
"url": "https://example.com"
},
"operationId": "getUserList",
"parameters": [
{
"$ref": "ex1.json"
}
],
"requestBody": {
"content": {}
},
"responses": {
"200": {
"description": "A JSON array of user names",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"201": {
"description": "A response"
}
}
},
"parameters": [
{
"name": "userId",
"in": "query",
"description": "ID of the user",
"required": true
}
]
}
}
}
Loading

0 comments on commit 16d5696

Please sign in to comment.