Skip to content

Commit

Permalink
do not assign required if array is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Aug 9, 2024
1 parent 06bc1a3 commit b776259
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import { joi2JsonInternal } from '../../parse';
import { processObject } from './object';

test.each([
[
schema.object({}),
{ type: 'object', properties: {}, additionalProperties: false, required: [] },
],
[schema.object({}), { type: 'object', properties: {}, additionalProperties: false }],
[
schema.object({ never: schema.never() }),
{ type: 'object', properties: {}, additionalProperties: false, required: [] },
{ type: 'object', properties: {}, additionalProperties: false },
],
[
schema.object(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const populateRequiredFields = (schema: OpenAPIV3.SchemaObject): void => {
}
}

schema.required = required;
if (required.length > 0) schema.required = required;
};

const removeNeverType = (schema: OpenAPIV3.SchemaObject): void => {
Expand Down

0 comments on commit b776259

Please sign in to comment.