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

Commit

Permalink
fix(oas2): fallback to https for missing schemes on HOST
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kylef committed Oct 13, 2020
1 parent 326a1b5 commit 9ce00cf
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@apielements/apib-parser": "^0.20.1",
"@apielements/apib-serializer": "^0.16.2",
"@apielements/core": ">=0.1.0 <0.3.0",
"@apielements/openapi2-parser": "^0.32.3",
"@apielements/openapi2-parser": "^0.32.4",
"@apielements/openapi3-parser": "^0.15.0",
"cardinal": "^2.1.1",
"commander": "^5.1.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/openapi2-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# API Elements: OpenAPI 2 Parser Changelog

## 0.32.4 (2020-10-13)

### Bug Fixes

- The HOST URI metadata produced from `schemes`, `host` and `basePath` will now
default to `https` when `schemes` is not defined. Previously a partial URI
without a scheme was returned.

## 0.32.3 (2020-08-06)

Adds compatibility for @apielements/core 0.2.0.
Expand Down
2 changes: 2 additions & 0 deletions packages/openapi2-parser/lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ class Parser {
}

hostname = `${this.swagger.schemes[0]}://${hostname}`;
} else {
hostname = `https://${hostname}`;
}

const metadata = [];
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi2-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apielements/openapi2-parser",
"version": "0.32.3",
"version": "0.32.4",
"description": "Swagger 2.0 parser for Fury.js",
"author": "Apiary.io <support@apiary.io>",
"license": "MIT",
Expand Down Expand Up @@ -38,7 +38,7 @@
"eslint": "^5.16.0",
"glob": "^7.1.2",
"mocha": "^7.1.1",
"swagger-zoo": "^3.1.3"
"swagger-zoo": "^3.1.4"
},
"engines": {
"node": ">=8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"value": {
"element": "string",
"content": "petstore.swagger.io"
"content": "https://petstore.swagger.io"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
},
"value": {
"element": "string",
"content": "petstore.swagger.io"
"content": "https://petstore.swagger.io"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"value": {
"element": "string",
"content": "petstore.swagger.io"
"content": "https://petstore.swagger.io"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
},
"value": {
"element": "string",
"content": "petstore.swagger.io"
"content": "https://petstore.swagger.io"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"value": {
"element": "string",
"content": "custom-instance.filter.ly"
"content": "https://custom-instance.filter.ly"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
},
"value": {
"element": "string",
"content": "custom-instance.filter.ly"
"content": "https://custom-instance.filter.ly"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/swagger-zoo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swagger-zoo",
"version": "3.1.3",
"version": "3.1.4",
"description": "Swagger example files for testing",
"author": "Apiary.io <support@apiary.io>",
"license": "MIT",
Expand Down

0 comments on commit 9ce00cf

Please sign in to comment.