Skip to content

Commit 7e601c4

Browse files
committed
test: test for issue cdimascio#590
1 parent cf304c1 commit 7e601c4

File tree

1 file changed

+235
-0
lines changed

1 file changed

+235
-0
lines changed

test/509.spec.ts

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
import * as request from 'supertest';
2+
import { createApp } from './common/app';
3+
4+
describe('509 schema.preprocessor', () => {
5+
let app = null;
6+
7+
before(async () => {
8+
// set up express app
9+
app = await createApp(
10+
{
11+
apiSpec: apiSpec(),
12+
},
13+
3001,
14+
(app) => {
15+
app.get('/v1/users/:user_id', (req, res) => {
16+
res.json([
17+
{
18+
id: 1,
19+
name: 'sparky',
20+
tag: 'test',
21+
},
22+
]);
23+
});
24+
},
25+
false,
26+
);
27+
return app;
28+
});
29+
30+
after(() => {
31+
app.server.close();
32+
});
33+
34+
it('should return 200', async () =>
35+
request(app).get(`${app.basePath}/users/aafasdf`).expect(200));
36+
});
37+
38+
function apiSpec(): any {
39+
return {
40+
openapi: '3.0.1',
41+
info: {
42+
title: 'service',
43+
version: 'v1',
44+
},
45+
// security: [
46+
// {
47+
// Authorizer: [],
48+
// },
49+
// ],
50+
servers: [
51+
{
52+
url: 'https://example.com/v1',
53+
description: 'NA',
54+
},
55+
{
56+
url: 'https://example.com/v1',
57+
description: 'NA',
58+
},
59+
],
60+
tags: [
61+
{
62+
name: 'Users',
63+
description: 'NA',
64+
},
65+
],
66+
paths: {
67+
'/users/{user_id}': {
68+
parameters: [
69+
{
70+
in: 'path',
71+
name: 'user_id',
72+
required: true,
73+
schema: {
74+
type: 'string',
75+
},
76+
},
77+
],
78+
get: {
79+
tags: ['Users'],
80+
description: 'NA',
81+
summary: 'NA',
82+
operationId: 'get-user',
83+
responses: {
84+
'200': {
85+
description: 'NA',
86+
content: {
87+
'application/json': {
88+
schema: {
89+
type: 'object',
90+
properties: {
91+
user_id: {
92+
type: 'string',
93+
},
94+
email: {
95+
type: 'string',
96+
format: 'email',
97+
},
98+
},
99+
required: ['user_id', 'email'],
100+
},
101+
},
102+
},
103+
},
104+
},
105+
},
106+
},
107+
},
108+
components: {
109+
parameters: {
110+
MemberId: {
111+
in: 'path',
112+
name: 'member_id',
113+
required: true,
114+
schema: {
115+
$ref: '#/components/schemas/MemberId',
116+
},
117+
},
118+
PartnerId: {
119+
in: 'path',
120+
name: 'partner_id',
121+
required: true,
122+
schema: {
123+
$ref: '#/components/schemas/PartnerId',
124+
},
125+
},
126+
},
127+
schemas: {
128+
Error: {
129+
type: 'object',
130+
},
131+
Deleted: {
132+
type: 'object',
133+
properties: {
134+
deleted: {
135+
type: 'boolean',
136+
description: 'NA',
137+
enum: [true],
138+
},
139+
},
140+
required: ['deleted'],
141+
},
142+
MemberId: {
143+
description: 'NA',
144+
type: 'string',
145+
format: 'uuid',
146+
},
147+
OrganizationId: {
148+
description: 'NA',
149+
type: 'string',
150+
format: 'uuid',
151+
},
152+
PartnerId: {
153+
description: 'NA',
154+
type: 'string',
155+
format: 'uuid',
156+
},
157+
Role: {
158+
type: 'string',
159+
description: 'NA',
160+
},
161+
Roles: {
162+
description: 'NA',
163+
type: 'array',
164+
items: {
165+
$ref: '#/components/schemas/Role',
166+
},
167+
},
168+
ApiKeyDescription: {
169+
description: 'NA',
170+
type: 'string',
171+
},
172+
173+
Member: {
174+
allOf: [
175+
{
176+
$ref: '#/components/schemas/Resource',
177+
},
178+
{
179+
type: 'object',
180+
properties: {
181+
member_id: {
182+
$ref: '#/components/schemas/MemberId',
183+
},
184+
organization_id: {
185+
$ref: '#/components/schemas/OrganizationId',
186+
},
187+
roles: {
188+
$ref: '#/components/schemas/Roles',
189+
},
190+
},
191+
required: ['member_id', 'organization_id', 'roles'],
192+
},
193+
],
194+
},
195+
Resource: {
196+
type: 'object',
197+
properties: {
198+
created_at: {
199+
type: 'string',
200+
format: 'date-time',
201+
},
202+
updated_at: {
203+
type: 'string',
204+
format: 'date-time',
205+
},
206+
},
207+
required: ['created_at', 'updated_at'],
208+
},
209+
},
210+
securitySchemes: {},
211+
responses: {
212+
UnprocessableEntity: {
213+
description: 'NA',
214+
content: {
215+
'application/json': {
216+
schema: {
217+
$ref: '#/components/schemas/Error',
218+
},
219+
},
220+
},
221+
},
222+
NotFound: {
223+
description: 'NA',
224+
content: {
225+
'application/json': {
226+
schema: {
227+
$ref: '#/components/schemas/Error',
228+
},
229+
},
230+
},
231+
},
232+
},
233+
},
234+
};
235+
}

0 commit comments

Comments
 (0)