Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 9ce00cf

Browse files
committed
fix(oas2): fallback to https for missing schemes on HOST
OpenAPI 2.0 specification states: > If the schemes is not included, the default scheme to be used is the > one used to access the Swagger definition itself.
1 parent 326a1b5 commit 9ce00cf

File tree

11 files changed

+20
-10
lines changed

11 files changed

+20
-10
lines changed

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@apielements/apib-parser": "^0.20.1",
2727
"@apielements/apib-serializer": "^0.16.2",
2828
"@apielements/core": ">=0.1.0 <0.3.0",
29-
"@apielements/openapi2-parser": "^0.32.3",
29+
"@apielements/openapi2-parser": "^0.32.4",
3030
"@apielements/openapi3-parser": "^0.15.0",
3131
"cardinal": "^2.1.1",
3232
"commander": "^5.1.0",

packages/openapi2-parser/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# API Elements: OpenAPI 2 Parser Changelog
22

3+
## 0.32.4 (2020-10-13)
4+
5+
### Bug Fixes
6+
7+
- The HOST URI metadata produced from `schemes`, `host` and `basePath` will now
8+
default to `https` when `schemes` is not defined. Previously a partial URI
9+
without a scheme was returned.
10+
311
## 0.32.3 (2020-08-06)
412

513
Adds compatibility for @apielements/core 0.2.0.

packages/openapi2-parser/lib/parser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ class Parser {
449449
}
450450

451451
hostname = `${this.swagger.schemes[0]}://${hostname}`;
452+
} else {
453+
hostname = `https://${hostname}`;
452454
}
453455

454456
const metadata = [];

packages/openapi2-parser/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@apielements/openapi2-parser",
3-
"version": "0.32.3",
3+
"version": "0.32.4",
44
"description": "Swagger 2.0 parser for Fury.js",
55
"author": "Apiary.io <support@apiary.io>",
66
"license": "MIT",
@@ -38,7 +38,7 @@
3838
"eslint": "^5.16.0",
3939
"glob": "^7.1.2",
4040
"mocha": "^7.1.1",
41-
"swagger-zoo": "^3.1.3"
41+
"swagger-zoo": "^3.1.4"
4242
},
4343
"engines": {
4444
"node": ">=8"

packages/openapi2-parser/test/fixtures/circular-example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"value": {
4848
"element": "string",
49-
"content": "petstore.swagger.io"
49+
"content": "https://petstore.swagger.io"
5050
}
5151
}
5252
}

packages/openapi2-parser/test/fixtures/circular-example.sourcemap.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
},
122122
"value": {
123123
"element": "string",
124-
"content": "petstore.swagger.io"
124+
"content": "https://petstore.swagger.io"
125125
}
126126
}
127127
}

packages/openapi2-parser/test/fixtures/invalid-media-type.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"value": {
4848
"element": "string",
49-
"content": "petstore.swagger.io"
49+
"content": "https://petstore.swagger.io"
5050
}
5151
}
5252
}

packages/openapi2-parser/test/fixtures/invalid-media-type.sourcemap.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
},
122122
"value": {
123123
"element": "string",
124-
"content": "petstore.swagger.io"
124+
"content": "https://petstore.swagger.io"
125125
}
126126
}
127127
}

packages/swagger-zoo/fixtures/features/api-elements/payload-as-string.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"value": {
4848
"element": "string",
49-
"content": "custom-instance.filter.ly"
49+
"content": "https://custom-instance.filter.ly"
5050
}
5151
}
5252
}

packages/swagger-zoo/fixtures/features/api-elements/payload-as-string.sourcemap.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
},
122122
"value": {
123123
"element": "string",
124-
"content": "custom-instance.filter.ly"
124+
"content": "https://custom-instance.filter.ly"
125125
}
126126
}
127127
}

0 commit comments

Comments
 (0)