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

Commit

Permalink
Merge pull request #210 from joolfe/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
joolfe authored Aug 28, 2022
2 parents e4cbd34 + 13653e5 commit f5ee60d
Show file tree
Hide file tree
Showing 10 changed files with 714 additions and 230 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function getVarValue (variables, name, def = undefined) {
/* calculate the type of a variable based on OPenApi types */
function inferType (value) {
if (/^\d+$/.test(value)) return 'integer'
if (/-?\d+\.\d+/.test(value)) return 'number'
if (/^[+-]?([0-9]*[.])?[0-9]+$/.test(value)) return 'number'
if (/^(true|false)$/.test(value)) return 'boolean'
return 'string'
}
Expand Down
836 changes: 628 additions & 208 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postman-to-openapi",
"version": "2.4.1",
"version": "2.4.2",
"description": "Convert postman collection to OpenAPI spec",
"main": "lib/index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -45,19 +45,19 @@
},
"homepage": "https://github.com/joolfe/postman-to-openapi#readme",
"devDependencies": {
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"eslint": "^8.16.0",
"@commitlint/cli": "^17.1.1",
"@commitlint/config-conventional": "^17.1.0",
"eslint": "^8.23.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.1",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-promise": "^6.0.1",
"execa": "^5.1.1",
"husky": "^7.0.4",
"mocha": "^10.0.0",
"nyc": "^15.1.0",
"typescript": "^4.5.4"
"typescript": "^4.8.2"
},
"commitlint": {
"extends": [
Expand Down Expand Up @@ -90,7 +90,7 @@
"commander": "^8.3.0",
"js-yaml": "^4.1.0",
"jsonc-parser": "3.1.0",
"marked": "^4.0.16",
"marked": "^4.0.19",
"mustache": "^4.2.0"
},
"husky": {
Expand Down
22 changes: 21 additions & 1 deletion test/resources/input/v2/GetMethods.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"method": "GET",
"header": [],
"url": {
"raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56&required=my value",
"raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56&required=my value&number1=0.4565876&number2=123.45&fake-number=1.23.45&date=2022-06-23T10:00:00.000+01:00",
"protocol": "https",
"host": [
"api",
Expand Down Expand Up @@ -46,6 +46,26 @@
"key": "required",
"value": "my value",
"description": "[required] mandatory paraemeter"
},
{
"key": "number1",
"value": "0.4565876",
"description": "Should be parsed as number"
},
{
"key": "number2",
"value": "123.45",
"description": "Should be parsed as number"
},
{
"key": "fake-number",
"value": "1.23.45",
"description": "Should be parsed as string"
},
{
"key": "date",
"value": "2022-06-23T10:00:00.000+01:00",
"description": "Should be parsed as string"
}
]
},
Expand Down
22 changes: 21 additions & 1 deletion test/resources/input/v21/GetMethods.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"method": "GET",
"header": [],
"url": {
"raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56&required=my value",
"raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56&required=my value&number1=0.4565876&number2=123.45&fake-number=1.23.45&date=2022-06-23T10:00:00.000+01:00",
"protocol": "https",
"host": [
"api",
Expand Down Expand Up @@ -46,6 +46,26 @@
"key": "required",
"value": "my value",
"description": "[required] mandatory paraemeter"
},
{
"key": "number1",
"value": "0.4565876",
"description": "Should be parsed as number"
},
{
"key": "number2",
"value": "123.45",
"description": "Should be parsed as number"
},
{
"key": "fake-number",
"value": "1.23.45",
"description": "Should be parsed as string"
},
{
"key": "date",
"value": "2022-06-23T10:00:00.000+01:00",
"description": "Should be parsed as string"
}
]
},
Expand Down
24 changes: 24 additions & 0 deletions test/resources/output/GetMethods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ paths:
required: true
description: mandatory paraemeter
example: my value
- name: number1
in: query
schema:
type: number
description: Should be parsed as number
example: '0.4565876'
- name: number2
in: query
schema:
type: number
description: Should be parsed as number
example: '123.45'
- name: fake-number
in: query
schema:
type: string
description: Should be parsed as string
example: 1.23.45
- name: date
in: query
schema:
type: string
description: Should be parsed as string
example: 2022-06-23T10:00:00.000 01:00
responses:
'200':
description: Successful response
Expand Down
6 changes: 3 additions & 3 deletions test/resources/output/JsonComments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ paths:
example: Sat, 05 Jun 2021 08:42:32 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down Expand Up @@ -153,7 +153,7 @@ paths:
example: Sat, 05 Jun 2021 08:48:00 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down Expand Up @@ -213,7 +213,7 @@ paths:
example: Sat, 05 Jun 2021 08:48:30 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
text/plain:
Expand Down
6 changes: 3 additions & 3 deletions test/resources/output/Responses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ paths:
example: Sat, 05 Jun 2021 08:42:32 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down Expand Up @@ -153,7 +153,7 @@ paths:
example: Sat, 05 Jun 2021 08:48:00 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down Expand Up @@ -213,7 +213,7 @@ paths:
example: Sat, 05 Jun 2021 08:48:30 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
text/plain:
Expand Down
6 changes: 3 additions & 3 deletions test/resources/output/ResponsesEmpty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ paths:
example: Sat, 05 Jun 2021 08:42:32 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down Expand Up @@ -152,7 +152,7 @@ paths:
example: Sat, 05 Jun 2021 08:48:00 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down Expand Up @@ -212,7 +212,7 @@ paths:
example: Sat, 05 Jun 2021 08:48:30 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
text/plain:
Expand Down
4 changes: 2 additions & 2 deletions test/resources/output/ResponsesMultiLang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ paths:
example: Sat, 05 Jun 2021 08:42:32 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down Expand Up @@ -147,7 +147,7 @@ paths:
example: Sat, 05 Jun 2021 08:48:00 GMT
Via:
schema:
type: number
type: string
example: 1.1 vegur
content:
application/json:
Expand Down

0 comments on commit f5ee60d

Please sign in to comment.