Common Api - createOne/Many (#15083)
closes https://github.com/twentyhq/core-team-issues/issues/1578
This commit is contained in:
+1
-2
@@ -62,8 +62,7 @@ describe('computeParameters', () => {
|
||||
in: 'query',
|
||||
description: `Determines the level of nested related objects to include in the response.
|
||||
- 0: Primary object only
|
||||
- 1: Primary object + direct relations
|
||||
- 2: Primary object + direct relations + nested relations`,
|
||||
- 1: Primary object + direct relations`,
|
||||
required: false,
|
||||
schema: {
|
||||
type: 'integer',
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
computeLimitParameters,
|
||||
computeOrderByParameters,
|
||||
computeStartingAfterParameters,
|
||||
computeUpsertParameters,
|
||||
} from 'src/engine/core-modules/open-api/utils/parameters.utils';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { convertObjectMetadataToSchemaProperties } from 'src/engine/utils/convert-object-metadata-to-schema-properties.util';
|
||||
@@ -208,6 +209,7 @@ export const computeParameterComponents = (
|
||||
endingBefore: computeEndingBeforeParameters(),
|
||||
filter: computeFilterParameters(),
|
||||
depth: computeDepthParameters(),
|
||||
upsert: computeUpsertParameters(),
|
||||
orderBy: computeOrderByParameters(),
|
||||
limit: computeLimitParameters(fromMetadata),
|
||||
};
|
||||
|
||||
@@ -51,8 +51,7 @@ export const computeDepthParameters = (): OpenAPIV3_1.ParameterObject => {
|
||||
in: 'query',
|
||||
description: `Determines the level of nested related objects to include in the response.
|
||||
- 0: Primary object only
|
||||
- 1: Primary object + direct relations
|
||||
- 2: Primary object + direct relations + nested relations`,
|
||||
- 1: Primary object + direct relations`,
|
||||
required: false,
|
||||
schema: {
|
||||
type: 'integer',
|
||||
@@ -62,6 +61,20 @@ export const computeDepthParameters = (): OpenAPIV3_1.ParameterObject => {
|
||||
};
|
||||
};
|
||||
|
||||
export const computeUpsertParameters = (): OpenAPIV3_1.ParameterObject => {
|
||||
return {
|
||||
name: 'upsert',
|
||||
in: 'query',
|
||||
description:
|
||||
'If true, creates the object or updates it if it already exists.',
|
||||
required: false,
|
||||
schema: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const computeFilterParameters = (): OpenAPIV3_1.ParameterObject => {
|
||||
return {
|
||||
name: 'filter',
|
||||
|
||||
@@ -27,7 +27,10 @@ export const computeBatchPath = (
|
||||
tags: [item.namePlural],
|
||||
summary: `Create Many ${item.namePlural}`,
|
||||
operationId: `createMany${capitalize(item.namePlural)}`,
|
||||
parameters: [{ $ref: '#/components/parameters/depth' }],
|
||||
parameters: [
|
||||
{ $ref: '#/components/parameters/depth' },
|
||||
{ $ref: '#/components/parameters/upsert' },
|
||||
],
|
||||
requestBody: getArrayRequestBody(capitalize(item.nameSingular)),
|
||||
responses: {
|
||||
'201': getCreateManyResponse201(item),
|
||||
@@ -65,7 +68,10 @@ export const computeManyResultPath = (
|
||||
tags: [item.namePlural],
|
||||
summary: `Create One ${item.nameSingular}`,
|
||||
operationId: `createOne${capitalize(item.nameSingular)}`,
|
||||
parameters: [{ $ref: '#/components/parameters/depth' }],
|
||||
parameters: [
|
||||
{ $ref: '#/components/parameters/depth' },
|
||||
{ $ref: '#/components/parameters/upsert' },
|
||||
],
|
||||
requestBody: getRequestBody(capitalize(item.nameSingular)),
|
||||
responses: {
|
||||
'201': getCreateOneResponse201(item),
|
||||
|
||||
Reference in New Issue
Block a user