Skip to content

Commit

Permalink
Remove discriminator from body
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Oct 24, 2024
1 parent c732b43 commit 6819ebe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const parseBody = (route, operation) => {
addPropertyToSchema(route.schema.headers, { 'content-type': { const: contentType } }, true);

// Sanitize schema.
removeAttributesFromSchema(schema, ['xml', 'example']);
removeAttributesFromSchema(schema, ['xml', 'example', 'discriminator']);

// Add request body schema.
route.schema.body = schema;
Expand Down
2 changes: 2 additions & 0 deletions src/parser/body.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe('parseBody()', () => {

it('should sanitize body schema', () => {
const schema = {
bar: { discriminator: { propertyName: 'type' }, type: 'object' },
foo: { example: 'baz', type: 'string', xml: { name: 'foo' } },
required: ['foo'],
xml: { name: 'Bar' }
Expand All @@ -84,6 +85,7 @@ describe('parseBody()', () => {
parseBody(route, { requestBody });

expect(route.schema.body).toStrictEqual({
bar: { type: 'object' },
foo: { type: 'string' },
required: ['foo']
});
Expand Down

0 comments on commit 6819ebe

Please sign in to comment.