Skip to content

Commit

Permalink
Merge 365bcf3 into bd14f60
Browse files Browse the repository at this point in the history
  • Loading branch information
gu-stav committed Aug 23, 2022
2 parents bd14f60 + 365bcf3 commit 4d2f722
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
[`${pascalCase(uniqueName)}LocalizationRequest`]: {
required: [...requiredAttributes, 'locale'],
type: 'object',
properties: cleanSchemaAttributes(attributesForRequest, { isRequest: true, addComponentSchema }),
properties: cleanSchemaAttributes(attributesForRequest, {
isRequest: true,
addComponentSchema,
}),
},
};
}
Expand All @@ -83,7 +86,10 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
data: {
required: requiredAttributes,
type: 'object',
properties: cleanSchemaAttributes(attributesForRequest, { isRequest: true, addComponentSchema }),
properties: cleanSchemaAttributes(attributesForRequest, {
isRequest: true,
addComponentSchema,
}),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ const pascalCase = require('./pascal-case');
*/
const cleanSchemaAttributes = (
attributes,
{ typeMap = new Map(), isRequest = false, addComponentSchema = () => {}, componentSchemaRefName = '' } = {}
{
typeMap = new Map(),
isRequest = false,
addComponentSchema = () => {},
componentSchemaRefName = '',
} = {}
) => {
const attributesCopy = _.cloneDeep(attributes);

Expand Down Expand Up @@ -125,7 +130,11 @@ const cleanSchemaAttributes = (
properties: {
...(isRequest ? {} : { id: { type: 'string' } }),
__component: { type: 'string' },
...cleanSchemaAttributes(componentAttributes, { typeMap, isRequest, addComponentSchema }),
...cleanSchemaAttributes(componentAttributes, {
typeMap,
isRequest,
addComponentSchema,
}),
},
};
const refComponentSchema = { $ref: `#/components/schemas/${pascalCase(component)}` };
Expand Down

0 comments on commit 4d2f722

Please sign in to comment.