Skip to content

Commit 2e376ed

Browse files
committed
Add validation for version and title
Add validation for version and title
1 parent 5666759 commit 2e376ed

File tree

12 files changed

+502
-36
lines changed

12 files changed

+502
-36
lines changed

lib/30XUtils/inputValidation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ module.exports = {
3939
}
4040

4141
if (!spec.info.hasOwnProperty('$ref')) {
42-
if (!spec.info.hasOwnProperty('title')) {
42+
if (!spec.info.hasOwnProperty('title') || !spec.info.title) {
4343
return {
4444
result: false,
4545
reason: 'Specification must contain a title in order to generate a collection'
4646
};
4747
}
4848

49-
if (!spec.info.hasOwnProperty('version')) {
49+
if (!spec.info.hasOwnProperty('version') || !spec.info.version) {
5050
return {
5151
result: false,
5252
reason: 'Specification must contain a semantic version number of the API in the Info Object'

lib/31XUtils/inputValidation31X.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ module.exports = {
3333
}
3434

3535
if (!spec.info.hasOwnProperty('$ref')) {
36-
if (!spec.info.hasOwnProperty('title')) {
36+
if (!spec.info.hasOwnProperty('title') || !spec.info.title) {
3737
return {
3838
result: false,
3939
reason: 'Specification must contain a title in order to generate a collection'
4040
};
4141
}
4242

43-
if (!spec.info.hasOwnProperty('version')) {
43+
if (!spec.info.hasOwnProperty('version') || !spec.info.version) {
4444
return {
4545
result: false,
4646
reason: 'Specification must contain a semantic version number of the API in the Info Object'

test/data/31CollectionTransactions/validateOptions/ignoreUnresolvedVariablesSpec.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: "3.1.0"
22
info:
33
version: 1.0.0
4-
title:
4+
title: a
55
license:
66
name: MIT
77
servers:
@@ -19,23 +19,23 @@ paths:
1919
required: true
2020
description: The id of the pet to retrieve
2121
schema:
22-
type:
22+
type:
2323
- integer
2424
example: '{{petIdCollectionVar}}'
2525
- name: sampleQueryParam
2626
in: query
2727
required: true
2828
description: The id of the pet to retrieve
2929
schema:
30-
type:
30+
type:
3131
- number
3232
example: '{{sampleQueryParamCollectionVar}}'
3333
- name: sampleHeader
3434
in: header
3535
required: true
3636
description: The id of the pet to retrieve
3737
schema:
38-
type:
38+
type:
3939
- boolean
4040
example: '{{sampleHeaderCollectionVar}}'
4141
requestBody:
@@ -53,33 +53,33 @@ paths:
5353
components:
5454
schemas:
5555
Pet:
56-
type:
56+
type:
5757
- object
5858
properties:
5959
petId:
60-
type:
60+
type:
6161
- integer
6262
format: int64
6363
name:
64-
type:
64+
type:
6565
- string
6666
tag:
67-
type:
67+
type:
6868
- string
6969
examples:
7070
- petId: '{{petIdVar}}'
7171
name: '{{nameVar}}'
7272
tag: '{{tagVar}}'
7373
Error:
74-
type:
74+
type:
7575
- object
7676
properties:
7777
code:
78-
type:
78+
type:
7979
- integer
8080
format: int32
8181
message:
82-
type:
82+
type:
8383
- string
8484
examples:
8585
- code: '{{codeVar}}'

test/data/31CollectionTransactions/validateOptions/suggestAvailableFixesSpec.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: "3.1.0"
22
info:
33
version: 1.0.0
4-
title:
4+
title: a
55
license:
66
name: MIT
77
servers:
@@ -19,26 +19,26 @@ paths:
1919
required: true
2020
description: The id of the pet to retrieve
2121
schema:
22-
type:
22+
type:
2323
- integer
24-
examples:
24+
examples:
2525
- 'Not an Integer'
2626
- name: limit
2727
in: query
2828
required: true
2929
schema:
30-
type:
30+
type:
3131
- number
32-
examples:
32+
examples:
3333
- 'Not a Number'
3434
- name: pet-quantity
3535
in: header
3636
description: Quantity of pets available
3737
required: true
3838
schema:
39-
type:
39+
type:
4040
- boolean
41-
examples:
41+
examples:
4242
- 'Not a Boolean'
4343
requestBody:
4444
content:
@@ -52,9 +52,9 @@ paths:
5252
X-Rate-Limit-Limit:
5353
description: The number of allowed requests in the current period
5454
schema:
55-
type:
55+
type:
5656
- integer
57-
examples:
57+
examples:
5858
- '<string>'
5959
content:
6060
application/json:
@@ -63,7 +63,7 @@ paths:
6363
components:
6464
schemas:
6565
Pet:
66-
type:
66+
type:
6767
- object
6868
required:
6969
- petId
@@ -72,36 +72,36 @@ components:
7272
- breeds
7373
properties:
7474
petId:
75-
type:
75+
type:
7676
- integer
7777
format: int64
7878
name:
79-
type:
79+
type:
8080
- string
8181
minLength: 30
8282
tag:
83-
type:
83+
type:
8484
- string
8585
breeds:
86-
type:
86+
type:
8787
- array
8888
minItems: 3
8989
maxItems: 3
9090
items:
91-
type:
91+
type:
9292
- string
9393
enum: ["Bulldog", "Retriever", "Timberwolf", "Grizzly", "Husky"]
9494
Error:
95-
type:
95+
type:
9696
- object
9797
properties:
9898
code:
99-
type:
99+
type:
100100
- integer
101101
format: int32
102102
multipleOf: 7
103103
message:
104-
type:
104+
type:
105105
- string
106106
examples:
107107
- code: '{{codeVar}}'
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"version": "1.0.0",
5+
"title": null
6+
},
7+
"version": "v1.0",
8+
"title": "API",
9+
"servers": [
10+
{
11+
"url": "http://localhost:3000"
12+
}
13+
],
14+
"paths": {
15+
"/user": {
16+
"get": {
17+
"summary": "Returns details about a particular user",
18+
"operationId": "listUser",
19+
"tags": [
20+
"user"
21+
],
22+
"parameters": [
23+
{
24+
"name": "id",
25+
"in": "query",
26+
"description": "ID of the user",
27+
"required": true,
28+
"schema": {
29+
"type": "integer",
30+
"format": "int32"
31+
}
32+
}
33+
],
34+
"responses": {
35+
"200": {
36+
"description": "Details about a user by ID",
37+
"headers": {
38+
"x-next": {
39+
"description": "A link to the next page of responses",
40+
"schema": {
41+
"type": "string"
42+
}
43+
}
44+
},
45+
"content": {
46+
"application/json": {
47+
"schema": {
48+
"$ref": "\\'#/components/schemas/User\\'"
49+
}
50+
}
51+
}
52+
},
53+
"default": {
54+
"description": "Unexpected error",
55+
"content": {
56+
"application/json": {
57+
"schema": {
58+
"$ref": "\\'#/components/schemas/Error\\'"
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
},
67+
"components": {
68+
"schemas": {
69+
"User": {
70+
"type": "object",
71+
"required": [
72+
"id",
73+
"name"
74+
],
75+
"properties": {
76+
"id": {
77+
"type": "integer",
78+
"format": "int64"
79+
},
80+
"name": {
81+
"type": "string"
82+
},
83+
"tag": {
84+
"type": "string"
85+
}
86+
}
87+
},
88+
"Error": {
89+
"type": "object",
90+
"required": [
91+
"code",
92+
"message"
93+
],
94+
"properties": {
95+
"code": {
96+
"type": "integer",
97+
"format": "int32"
98+
},
99+
"message": {
100+
"type": "string"
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)