700 fix rest api issues (#11326)
fixes issues listed here https://github.com/twentyhq/core-team-issues/issues/700
This commit is contained in:
@ -174,16 +174,6 @@ export class OpenApiService {
|
||||
},
|
||||
} as OpenAPIV3_1.PathItemObject;
|
||||
path[`/${item.namePlural}/{id}`] = {
|
||||
get: {
|
||||
tags: [item.namePlural],
|
||||
summary: `Find One ${item.nameSingular}`,
|
||||
parameters: [{ $ref: '#/components/parameters/idPath' }],
|
||||
responses: {
|
||||
'200': getFindOneResponse200(item),
|
||||
'400': { $ref: '#/components/responses/400' },
|
||||
'401': { $ref: '#/components/responses/401' },
|
||||
},
|
||||
},
|
||||
delete: {
|
||||
tags: [item.namePlural],
|
||||
summary: `Delete One ${item.nameSingular}`,
|
||||
@ -196,6 +186,16 @@ export class OpenApiService {
|
||||
},
|
||||
},
|
||||
...(item.nameSingular !== 'relation' && {
|
||||
get: {
|
||||
tags: [item.namePlural],
|
||||
summary: `Find One ${item.nameSingular}`,
|
||||
parameters: [{ $ref: '#/components/parameters/idPath' }],
|
||||
responses: {
|
||||
'200': getFindOneResponse200(item),
|
||||
'400': { $ref: '#/components/responses/400' },
|
||||
'401': { $ref: '#/components/responses/401' },
|
||||
},
|
||||
},
|
||||
patch: {
|
||||
tags: [item.namePlural],
|
||||
summary: `Update One ${item.nameSingular}`,
|
||||
|
||||
@ -10,6 +10,9 @@ export const getFindManyResponse200 = (
|
||||
item.nameSingular,
|
||||
)} for Response`;
|
||||
|
||||
const namePlural =
|
||||
item.namePlural === 'relations' ? 'relationMetadata' : item.namePlural;
|
||||
|
||||
return {
|
||||
description: 'Successful operation',
|
||||
content: {
|
||||
@ -20,7 +23,7 @@ export const getFindManyResponse200 = (
|
||||
data: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
[item.namePlural]: {
|
||||
[namePlural]: {
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: schemaRef,
|
||||
@ -86,7 +89,11 @@ export const getCreateOneResponse201 = (
|
||||
fromMetadata = false,
|
||||
) => {
|
||||
const one = fromMetadata ? 'One' : '';
|
||||
const schemaRef = `#/components/schemas/${capitalize(item.nameSingular)} for Response`;
|
||||
|
||||
const nameSingular =
|
||||
item.nameSingular === 'relation' ? 'relationMetadata' : item.nameSingular;
|
||||
|
||||
const schemaRef = `#/components/schemas/${capitalize(nameSingular)} for Response`;
|
||||
|
||||
return {
|
||||
description: 'Successful operation',
|
||||
@ -98,7 +105,7 @@ export const getCreateOneResponse201 = (
|
||||
data: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
[`create${one}${capitalize(item.nameSingular)}`]: {
|
||||
[`create${one}${capitalize(nameSingular)}`]: {
|
||||
$ref: schemaRef,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user