ID in schema have type string

This commit is contained in:
gitstart 2022-08-31 10:37:08 +00:00
commit 6b94965574
5 changed files with 35 additions and 7 deletions

View File

@ -147,7 +147,7 @@
"deprecated": false,
"required": true,
"schema": {
"type": "string"
"type": "number"
}
}
],

View File

@ -46,7 +46,7 @@ const getPathParams = (routePath) => {
description: '',
deprecated: false,
required: true,
schema: { type: 'string' },
schema: { type: 'number' },
};
});
};

View File

@ -102,8 +102,8 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
[`${pascalCase(uniqueName)}LocalizationResponse`]: {
type: 'object',
properties: {
id: { type: 'string' },
...cleanSchemaAttributes(attributes, { addComponentSchema }),
id: { type: 'number' },
...cleanSchemaAttributes(attributes),
},
},
};
@ -145,6 +145,11 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
data: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'number' },
attributes: { type: 'object', properties: cleanSchemaAttributes(attributes) },
},
$ref: `#/components/schemas/${pascalCase(uniqueName)}ListResponseDataItem`,
},
},
@ -175,6 +180,10 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
id: { type: 'string' },
attributes: {
type: 'object',
properties: {
id: { type: 'number' },
attributes: { type: 'object', properties: cleanSchemaAttributes(attributes) },
},
properties: cleanSchemaAttributes(attributes, {
addComponentSchema,
componentSchemaRefName: `#/components/schemas/${pascalCase(

View File

@ -115,6 +115,25 @@ const cleanSchemaAttributes = (
if (attribute.repeatable) {
attributesCopy[prop] = {
type: 'array',
items: {
type: 'object',
properties: {
...(isRequest ? {} : { id: { type: 'number' } }),
...cleanSchemaAttributes(componentAttributes, { typeMap, isRequest }),
},
},
};
} else {
attributesCopy[prop] = {
type: 'object',
properties: {
...(isRequest ? {} : { id: { type: 'number' } }),
...cleanSchemaAttributes(componentAttributes, {
typeMap,
isRequest,
}),
},
};
items: finalComponentSchema,
};
} else {
@ -128,7 +147,7 @@ const cleanSchemaAttributes = (
const rawComponentSchema = {
type: 'object',
properties: {
...(isRequest ? {} : { id: { type: 'string' } }),
...(isRequest ? {} : { id: { type: 'number' } }),
__component: { type: 'string' },
...cleanSchemaAttributes(componentAttributes, {
typeMap,

View File

@ -15,7 +15,7 @@ module.exports = (isListOfEntities, attributes) => {
items: {
type: 'object',
properties: {
id: { type: 'string' },
id: { type: 'number' },
attributes: { type: 'object', properties: attributes },
},
},
@ -25,7 +25,7 @@ module.exports = (isListOfEntities, attributes) => {
return {
type: 'object',
properties: {
id: { type: 'string' },
id: { type: 'number' },
attributes: { type: 'object', properties: attributes },
},
};