@openaddresses/batch-schema 10.26.0 → 10.28.1
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/.github/workflows/test.yml +19 -19
- package/CHANGELOG.md +19 -0
- package/README.md +14 -0
- package/dist/lib/openapi.js +2 -0
- package/dist/lib/openapi.js.map +1 -1
- package/dist/lib/schema.d.ts +35 -12
- package/dist/lib/schema.js +134 -217
- package/dist/lib/schema.js.map +1 -1
- package/dist/lib/types.d.ts +6 -0
- package/dist/test/response.srv.test.d.ts +1 -0
- package/dist/test/response.srv.test.js +95 -0
- package/dist/test/response.srv.test.js.map +1 -0
- package/dist/test/schema.srv.test.js +25 -0
- package/dist/test/schema.srv.test.js.map +1 -1
- package/lib/openapi.ts +2 -0
- package/lib/schema.ts +170 -226
- package/lib/types.ts +6 -0
- package/package.json +1 -1
- package/test/response.srv.test.ts +114 -0
- package/test/schema.srv.test.ts +28 -0
package/test/schema.srv.test.ts
CHANGED
|
@@ -24,6 +24,17 @@ describe('Schema Server', () => {
|
|
|
24
24
|
res.json({ ok: true });
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
await schema.get('/secured', {
|
|
28
|
+
description: 'Route with operation level security',
|
|
29
|
+
security: [
|
|
30
|
+
{ bearerAuth: [] },
|
|
31
|
+
{ layerAuth: ['search:read'] }
|
|
32
|
+
],
|
|
33
|
+
res: Type.Object({ ok: Type.Boolean() })
|
|
34
|
+
}, async (_, res) => {
|
|
35
|
+
res.json({ ok: true });
|
|
36
|
+
});
|
|
37
|
+
|
|
27
38
|
await schema.post('/json-only', {
|
|
28
39
|
description: 'Backwards compatible JSON body',
|
|
29
40
|
body: Type.Object({
|
|
@@ -113,6 +124,11 @@ describe('Schema Server', () => {
|
|
|
113
124
|
query: false,
|
|
114
125
|
res: true
|
|
115
126
|
},
|
|
127
|
+
'GET /secured': {
|
|
128
|
+
body: false,
|
|
129
|
+
query: false,
|
|
130
|
+
res: true
|
|
131
|
+
},
|
|
116
132
|
'POST /json-only': {
|
|
117
133
|
body: true,
|
|
118
134
|
query: false,
|
|
@@ -219,6 +235,18 @@ describe('Schema Server', () => {
|
|
|
219
235
|
assert.strictEqual(body.paths['/schema'].get.deprecated, false);
|
|
220
236
|
});
|
|
221
237
|
|
|
238
|
+
it('GET: api/openapi emits operation level security', async () => {
|
|
239
|
+
const res = await fetch('http://localhost:2000/api/openapi');
|
|
240
|
+
const body = await res.json();
|
|
241
|
+
|
|
242
|
+
assert.strictEqual(res.status, 200, 'http: 200');
|
|
243
|
+
assert.deepStrictEqual(body.paths['/secured'].get.security, [
|
|
244
|
+
{ bearerAuth: [] },
|
|
245
|
+
{ layerAuth: ['search:read'] }
|
|
246
|
+
]);
|
|
247
|
+
assert.strictEqual(body.paths['/legacy'].get.security, undefined);
|
|
248
|
+
});
|
|
249
|
+
|
|
222
250
|
it('POST: /json-only with valid JSON body (backwards compat)', async () => {
|
|
223
251
|
const res = await fetch('http://localhost:2000/api/json-only', {
|
|
224
252
|
method: 'POST',
|