@schmock/openapi 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crud-detector.d.ts +35 -0
- package/dist/crud-detector.d.ts.map +1 -0
- package/dist/crud-detector.js +153 -0
- package/dist/generators.d.ts +14 -0
- package/dist/generators.d.ts.map +1 -0
- package/dist/generators.js +158 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +221 -0
- package/dist/normalizer.d.ts +14 -0
- package/dist/normalizer.d.ts.map +1 -0
- package/dist/normalizer.js +194 -0
- package/dist/parser.d.ts +32 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +282 -0
- package/dist/plugin.d.ts +32 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +129 -0
- package/dist/seed.d.ts +15 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +41 -0
- package/package.json +45 -0
- package/src/__fixtures__/faker-stress-test.openapi.yaml +1030 -0
- package/src/__fixtures__/openapi31.json +34 -0
- package/src/__fixtures__/petstore-openapi3.json +168 -0
- package/src/__fixtures__/petstore-swagger2.json +141 -0
- package/src/__fixtures__/scalar-galaxy.yaml +1314 -0
- package/src/__fixtures__/stripe-fixtures3.json +6542 -0
- package/src/__fixtures__/stripe-spec3.yaml +161621 -0
- package/src/__fixtures__/train-travel.yaml +1264 -0
- package/src/crud-detector.test.ts +150 -0
- package/src/crud-detector.ts +194 -0
- package/src/generators.test.ts +214 -0
- package/src/generators.ts +212 -0
- package/src/index.ts +4 -0
- package/src/normalizer.test.ts +253 -0
- package/src/normalizer.ts +233 -0
- package/src/parser.test.ts +181 -0
- package/src/parser.ts +389 -0
- package/src/plugin.test.ts +205 -0
- package/src/plugin.ts +185 -0
- package/src/seed.ts +62 -0
- package/src/steps/openapi-crud.steps.ts +132 -0
- package/src/steps/openapi-parsing.steps.ts +111 -0
- package/src/steps/openapi-seed.steps.ts +94 -0
- package/src/stress.test.ts +2814 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.1.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Simple API",
|
|
5
|
+
"version": "3.1.0"
|
|
6
|
+
},
|
|
7
|
+
"paths": {
|
|
8
|
+
"/items": {
|
|
9
|
+
"get": {
|
|
10
|
+
"operationId": "listItems",
|
|
11
|
+
"responses": {
|
|
12
|
+
"200": {
|
|
13
|
+
"description": "List of items",
|
|
14
|
+
"content": {
|
|
15
|
+
"application/json": {
|
|
16
|
+
"schema": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"itemId": { "type": "integer" },
|
|
22
|
+
"title": { "type": "string" }
|
|
23
|
+
},
|
|
24
|
+
"required": ["itemId", "title"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.3",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Petstore",
|
|
5
|
+
"version": "2.0.0"
|
|
6
|
+
},
|
|
7
|
+
"servers": [{ "url": "http://localhost:3000/v2" }],
|
|
8
|
+
"paths": {
|
|
9
|
+
"/pets": {
|
|
10
|
+
"get": {
|
|
11
|
+
"operationId": "listPets",
|
|
12
|
+
"tags": ["pets"],
|
|
13
|
+
"parameters": [
|
|
14
|
+
{
|
|
15
|
+
"name": "limit",
|
|
16
|
+
"in": "query",
|
|
17
|
+
"required": false,
|
|
18
|
+
"schema": { "type": "integer" }
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"responses": {
|
|
22
|
+
"200": {
|
|
23
|
+
"description": "A list of pets",
|
|
24
|
+
"content": {
|
|
25
|
+
"application/json": {
|
|
26
|
+
"schema": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": {
|
|
29
|
+
"$ref": "#/components/schemas/Pet"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"post": {
|
|
38
|
+
"operationId": "createPet",
|
|
39
|
+
"tags": ["pets"],
|
|
40
|
+
"requestBody": {
|
|
41
|
+
"required": true,
|
|
42
|
+
"content": {
|
|
43
|
+
"application/json": {
|
|
44
|
+
"schema": {
|
|
45
|
+
"$ref": "#/components/schemas/NewPet"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"responses": {
|
|
51
|
+
"201": {
|
|
52
|
+
"description": "Pet created",
|
|
53
|
+
"content": {
|
|
54
|
+
"application/json": {
|
|
55
|
+
"schema": {
|
|
56
|
+
"$ref": "#/components/schemas/Pet"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"/pets/{petId}": {
|
|
65
|
+
"parameters": [
|
|
66
|
+
{
|
|
67
|
+
"name": "petId",
|
|
68
|
+
"in": "path",
|
|
69
|
+
"required": true,
|
|
70
|
+
"schema": { "type": "integer" }
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"get": {
|
|
74
|
+
"operationId": "getPet",
|
|
75
|
+
"tags": ["pets"],
|
|
76
|
+
"responses": {
|
|
77
|
+
"200": {
|
|
78
|
+
"description": "A pet",
|
|
79
|
+
"content": {
|
|
80
|
+
"application/json": {
|
|
81
|
+
"schema": {
|
|
82
|
+
"$ref": "#/components/schemas/Pet"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"put": {
|
|
90
|
+
"operationId": "updatePet",
|
|
91
|
+
"tags": ["pets"],
|
|
92
|
+
"requestBody": {
|
|
93
|
+
"content": {
|
|
94
|
+
"application/json": {
|
|
95
|
+
"schema": {
|
|
96
|
+
"$ref": "#/components/schemas/NewPet"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"responses": {
|
|
102
|
+
"200": {
|
|
103
|
+
"description": "Updated pet"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"delete": {
|
|
108
|
+
"operationId": "deletePet",
|
|
109
|
+
"tags": ["pets"],
|
|
110
|
+
"responses": {
|
|
111
|
+
"204": {
|
|
112
|
+
"description": "Pet deleted"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"/owners/{ownerId}/pets": {
|
|
118
|
+
"get": {
|
|
119
|
+
"operationId": "listOwnerPets",
|
|
120
|
+
"tags": ["owners"],
|
|
121
|
+
"parameters": [
|
|
122
|
+
{
|
|
123
|
+
"name": "ownerId",
|
|
124
|
+
"in": "path",
|
|
125
|
+
"required": true,
|
|
126
|
+
"schema": { "type": "integer" }
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"responses": {
|
|
130
|
+
"200": {
|
|
131
|
+
"description": "Owner's pets",
|
|
132
|
+
"content": {
|
|
133
|
+
"application/json": {
|
|
134
|
+
"schema": {
|
|
135
|
+
"type": "array",
|
|
136
|
+
"items": {
|
|
137
|
+
"$ref": "#/components/schemas/Pet"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"components": {
|
|
148
|
+
"schemas": {
|
|
149
|
+
"Pet": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"required": ["petId", "name"],
|
|
152
|
+
"properties": {
|
|
153
|
+
"petId": { "type": "integer", "readOnly": true },
|
|
154
|
+
"name": { "type": "string", "example": "Buddy" },
|
|
155
|
+
"tag": { "type": "string", "nullable": true }
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"NewPet": {
|
|
159
|
+
"type": "object",
|
|
160
|
+
"required": ["name"],
|
|
161
|
+
"properties": {
|
|
162
|
+
"name": { "type": "string" },
|
|
163
|
+
"tag": { "type": "string" }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
{
|
|
2
|
+
"swagger": "2.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Petstore",
|
|
5
|
+
"version": "1.0.0"
|
|
6
|
+
},
|
|
7
|
+
"basePath": "/api",
|
|
8
|
+
"paths": {
|
|
9
|
+
"/pets": {
|
|
10
|
+
"get": {
|
|
11
|
+
"operationId": "listPets",
|
|
12
|
+
"tags": ["pets"],
|
|
13
|
+
"parameters": [
|
|
14
|
+
{
|
|
15
|
+
"name": "limit",
|
|
16
|
+
"in": "query",
|
|
17
|
+
"type": "integer",
|
|
18
|
+
"required": false
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"responses": {
|
|
22
|
+
"200": {
|
|
23
|
+
"description": "A list of pets",
|
|
24
|
+
"schema": {
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"required": ["petId", "name"],
|
|
29
|
+
"properties": {
|
|
30
|
+
"petId": { "type": "integer" },
|
|
31
|
+
"name": { "type": "string" },
|
|
32
|
+
"tag": { "type": "string" }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"post": {
|
|
40
|
+
"operationId": "createPet",
|
|
41
|
+
"tags": ["pets"],
|
|
42
|
+
"parameters": [
|
|
43
|
+
{
|
|
44
|
+
"name": "body",
|
|
45
|
+
"in": "body",
|
|
46
|
+
"required": true,
|
|
47
|
+
"schema": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"required": ["name"],
|
|
50
|
+
"properties": {
|
|
51
|
+
"name": { "type": "string" },
|
|
52
|
+
"tag": { "type": "string" }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"responses": {
|
|
58
|
+
"201": {
|
|
59
|
+
"description": "Pet created"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"/pets/{petId}": {
|
|
65
|
+
"parameters": [
|
|
66
|
+
{
|
|
67
|
+
"name": "petId",
|
|
68
|
+
"in": "path",
|
|
69
|
+
"type": "integer",
|
|
70
|
+
"required": true
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"get": {
|
|
74
|
+
"operationId": "getPet",
|
|
75
|
+
"tags": ["pets"],
|
|
76
|
+
"responses": {
|
|
77
|
+
"200": {
|
|
78
|
+
"description": "A pet",
|
|
79
|
+
"schema": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"required": ["petId", "name"],
|
|
82
|
+
"properties": {
|
|
83
|
+
"petId": { "type": "integer" },
|
|
84
|
+
"name": { "type": "string" },
|
|
85
|
+
"tag": { "type": "string" }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"put": {
|
|
92
|
+
"operationId": "updatePet",
|
|
93
|
+
"tags": ["pets"],
|
|
94
|
+
"parameters": [
|
|
95
|
+
{
|
|
96
|
+
"name": "body",
|
|
97
|
+
"in": "body",
|
|
98
|
+
"required": true,
|
|
99
|
+
"schema": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"properties": {
|
|
102
|
+
"name": { "type": "string" },
|
|
103
|
+
"tag": { "type": "string" }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"responses": {
|
|
109
|
+
"200": {
|
|
110
|
+
"description": "Pet updated"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"delete": {
|
|
115
|
+
"operationId": "deletePet",
|
|
116
|
+
"tags": ["pets"],
|
|
117
|
+
"responses": {
|
|
118
|
+
"204": {
|
|
119
|
+
"description": "Pet deleted"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"/health": {
|
|
125
|
+
"get": {
|
|
126
|
+
"operationId": "healthCheck",
|
|
127
|
+
"responses": {
|
|
128
|
+
"200": {
|
|
129
|
+
"description": "Service health",
|
|
130
|
+
"schema": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": {
|
|
133
|
+
"status": { "type": "string" }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|