Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit aab1c77

Browse files
author
Dom Harrington
committed
Make sure enums are passed through
1 parent 0255baf commit aab1c77

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

packages/api-explorer-ui/__tests__/lib/parameters-to-json-schema.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,38 @@ test('it should work for request body inline', () => {
107107
]);
108108
});
109109

110+
test('should pass through enum', () => {
111+
expect(
112+
parametersToJsonSchema({
113+
parameters: [
114+
{
115+
in: 'header',
116+
name: 'Accept',
117+
required: false,
118+
schema: {
119+
type: 'string',
120+
enum: ['application/json', 'application/xml'],
121+
}
122+
},
123+
],
124+
}),
125+
).toEqual([
126+
{
127+
label: 'Headers',
128+
type: 'header',
129+
schema: {
130+
type: 'object',
131+
properties: {
132+
Accept: {
133+
type: 'string',
134+
enum: ['application/json', 'application/xml'],
135+
}
136+
},
137+
required: [],
138+
},
139+
},
140+
]);
141+
});
110142
test.skip('it should work for top-level request body $ref', () => {
111143
expect(
112144
parametersToJsonSchema(

packages/api-explorer-ui/src/lib/parameters-to-json-schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = pathOperation => {
4545
schema.type = 'array';
4646
schema.items = current.schema.items;
4747
}
48+
if (current.schema.enum) schema.enum = current.schema.enum;
4849
}
4950

5051
prev[current.name] = schema;

0 commit comments

Comments
 (0)