From f39e14ae31e7f579ff57cdeaf501c8c89c8ba277 Mon Sep 17 00:00:00 2001 From: "ct-sdks[bot]" <153784748+ct-sdks[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 07:21:12 +0000 Subject: [PATCH] Updated API from documentation release --- api-specs/api/ruleset.xml | 3 ++ api-specs/api/types/annotations.raml | 3 ++ api-specs/api/types/common/BaseAddress.raml | 1 + api-specs/api/types/common/BaseResource.raml | 1 + api-specs/api/types/common/ClientLogging.raml | 1 + api-specs/api/types/common/Money.raml | 1 + api-specs/api/types/error/ErrorResponse.raml | 1 + api-specs/api/types/message/OrderMessage.raml | 1 + .../message/payload/OrderMessagePayload.raml | 1 + .../OrderSearchCompoundExpression.raml | 1 + .../OrderSearchQueryExpression.raml | 1 + .../OrderSearchQueryExpressionValue.raml | 1 + api-specs/api/types/order/Order.raml | 1 + .../api/types/order/OrderSearchQuery.raml | 1 + .../facets/ProductSearchFacetExpression.raml | 1 + .../facets/ProductSearchFacetResult.raml | 1 + .../search/SearchCompoundExpression.raml | 1 + api-specs/api/types/search/SearchQuery.raml | 1 + .../types/search/SearchQueryExpression.raml | 1 + .../search/SearchQueryExpressionValue.raml | 1 + api-specs/readme.md | 30 +++++++++++++++++++ 21 files changed, 54 insertions(+) diff --git a/api-specs/api/ruleset.xml b/api-specs/api/ruleset.xml index 0c5033c0c..05b9e9168 100644 --- a/api-specs/api/ruleset.xml +++ b/api-specs/api/ruleset.xml @@ -107,6 +107,9 @@ com.commercetools.rmf.validators.DatetimeRule + + com.commercetools.rmf.validators.PolymorphicSubtypesRule + com.commercetools.rmf.validators.CamelCaseRule diff --git a/api-specs/api/types/annotations.raml b/api-specs/api/types/annotations.raml index adf30fd13..11816d73d 100644 --- a/api-specs/api/types/annotations.raml +++ b/api-specs/api/types/annotations.raml @@ -4,6 +4,9 @@ package: identifier: type: boolean allowedTargets: TypeDeclaration +ignoreValidators: + type: string[] + allowedTargets: TypeDeclaration elementIdentifier: type: boolean allowedTargets: TypeDeclaration diff --git a/api-specs/api/types/common/BaseAddress.raml b/api-specs/api/types/common/BaseAddress.raml index 797a48cae..959f35982 100644 --- a/api-specs/api/types/common/BaseAddress.raml +++ b/api-specs/api/types/common/BaseAddress.raml @@ -6,6 +6,7 @@ description: | Polymorphic base type that represents a postal address and contact details. Depending on the read or write action, it can be either [Address](ctp:api:type:Address) or [AddressDraft](ctp:api:type:AddressDraft) that only differ in the data type for the optional `custom` field. +(ignoreValidators): [PolymorphicSubtypesRule] properties: id?: type: string diff --git a/api-specs/api/types/common/BaseResource.raml b/api-specs/api/types/common/BaseResource.raml index e06d44592..8327310ad 100644 --- a/api-specs/api/types/common/BaseResource.raml +++ b/api-specs/api/types/common/BaseResource.raml @@ -3,6 +3,7 @@ displayName: BaseResource type: object (abstract): true +(ignoreValidators): [PolymorphicSubtypesRule] properties: id: (identifier): true diff --git a/api-specs/api/types/common/ClientLogging.raml b/api-specs/api/types/common/ClientLogging.raml index d923e3492..f06d8d09d 100644 --- a/api-specs/api/types/common/ClientLogging.raml +++ b/api-specs/api/types/common/ClientLogging.raml @@ -4,6 +4,7 @@ displayName: ClientLogging type: object description: | These objects represent information about which [API Client](/../api/projects/api-clients) created or modified a resource. For more information, see [Client Logging](/../api/general-concepts#client-logging). +(ignoreValidators): [PolymorphicSubtypesRule] properties: clientId?: type: string diff --git a/api-specs/api/types/common/Money.raml b/api-specs/api/types/common/Money.raml index 9390169d3..074a7fd6b 100644 --- a/api-specs/api/types/common/Money.raml +++ b/api-specs/api/types/common/Money.raml @@ -5,6 +5,7 @@ type: object description: | Draft type that stores amounts only in cent precision for the specified currency. example: !include ../../examples/Common/Money.json +(ignoreValidators): [PolymorphicSubtypesRule] properties: centAmount: type: number diff --git a/api-specs/api/types/error/ErrorResponse.raml b/api-specs/api/types/error/ErrorResponse.raml index d939c6883..430cc1dc8 100644 --- a/api-specs/api/types/error/ErrorResponse.raml +++ b/api-specs/api/types/error/ErrorResponse.raml @@ -5,6 +5,7 @@ displayName: ErrorResponse description: | Base representation of an error response containing common fields to all errors. example: !include /../../examples/Error/ErrorResponse.json +(ignoreValidators): [PolymorphicSubtypesRule] properties: statusCode: type: integer diff --git a/api-specs/api/types/message/OrderMessage.raml b/api-specs/api/types/message/OrderMessage.raml index c2f88ab94..7e1ec97a6 100644 --- a/api-specs/api/types/message/OrderMessage.raml +++ b/api-specs/api/types/message/OrderMessage.raml @@ -1,4 +1,5 @@ #%RAML 1.0 DataType (package): Message type: Message +(ignoreValidators): [PolymorphicSubtypesRule] displayName: OrderMessage diff --git a/api-specs/api/types/message/payload/OrderMessagePayload.raml b/api-specs/api/types/message/payload/OrderMessagePayload.raml index 0f762d4a1..ee119a7eb 100644 --- a/api-specs/api/types/message/payload/OrderMessagePayload.raml +++ b/api-specs/api/types/message/payload/OrderMessagePayload.raml @@ -1,4 +1,5 @@ #%RAML 1.0 DataType (package): Message type: MessagePayload +(ignoreValidators): [PolymorphicSubtypesRule] displayName: OrderMessagePayload diff --git a/api-specs/api/types/order-search/OrderSearchCompoundExpression.raml b/api-specs/api/types/order-search/OrderSearchCompoundExpression.raml index d52e49cb0..8842daaaa 100644 --- a/api-specs/api/types/order-search/OrderSearchCompoundExpression.raml +++ b/api-specs/api/types/order-search/OrderSearchCompoundExpression.raml @@ -2,3 +2,4 @@ (package): Order type: OrderSearchQuery displayName: OrderSearchCompoundExpression +(ignoreValidators): [PolymorphicSubtypesRule] diff --git a/api-specs/api/types/order-search/OrderSearchQueryExpression.raml b/api-specs/api/types/order-search/OrderSearchQueryExpression.raml index 53ef4bbc9..b6499c643 100644 --- a/api-specs/api/types/order-search/OrderSearchQueryExpression.raml +++ b/api-specs/api/types/order-search/OrderSearchQueryExpression.raml @@ -2,3 +2,4 @@ (package): Order type: OrderSearchQuery displayName: OrderSearchQueryExpression +(ignoreValidators): [PolymorphicSubtypesRule] diff --git a/api-specs/api/types/order-search/OrderSearchQueryExpressionValue.raml b/api-specs/api/types/order-search/OrderSearchQueryExpressionValue.raml index 3bcbc33df..439774ec9 100644 --- a/api-specs/api/types/order-search/OrderSearchQueryExpressionValue.raml +++ b/api-specs/api/types/order-search/OrderSearchQueryExpressionValue.raml @@ -2,6 +2,7 @@ (package): Order type: object displayName: OrderSearchQueryExpressionValue +(ignoreValidators): [PolymorphicSubtypesRule] properties: field: type: string diff --git a/api-specs/api/types/order/Order.raml b/api-specs/api/types/order/Order.raml index 83fee30c9..9a1d0e4b7 100644 --- a/api-specs/api/types/order/Order.raml +++ b/api-specs/api/types/order/Order.raml @@ -3,6 +3,7 @@ displayName: Order (updateType): OrderUpdate type: BaseResource +(ignoreValidators): [PolymorphicSubtypesRule] properties: id: (identifier): true diff --git a/api-specs/api/types/order/OrderSearchQuery.raml b/api-specs/api/types/order/OrderSearchQuery.raml index 633f6ae68..ce63a92fb 100644 --- a/api-specs/api/types/order/OrderSearchQuery.raml +++ b/api-specs/api/types/order/OrderSearchQuery.raml @@ -2,3 +2,4 @@ (package): Order type: object displayName: OrderSearchQuery +(ignoreValidators): [PolymorphicSubtypesRule] diff --git a/api-specs/api/types/product-search/facets/ProductSearchFacetExpression.raml b/api-specs/api/types/product-search/facets/ProductSearchFacetExpression.raml index 0308847e6..250304e0f 100644 --- a/api-specs/api/types/product-search/facets/ProductSearchFacetExpression.raml +++ b/api-specs/api/types/product-search/facets/ProductSearchFacetExpression.raml @@ -3,3 +3,4 @@ type: object (beta): true displayName: ProductSearchFacetExpression +(ignoreValidators): [PolymorphicSubtypesRule] diff --git a/api-specs/api/types/product-search/facets/ProductSearchFacetResult.raml b/api-specs/api/types/product-search/facets/ProductSearchFacetResult.raml index c5a0873d0..4bdcdbbe1 100644 --- a/api-specs/api/types/product-search/facets/ProductSearchFacetResult.raml +++ b/api-specs/api/types/product-search/facets/ProductSearchFacetResult.raml @@ -3,6 +3,7 @@ displayName: ProductSearchFacetResult type: object (beta): true +(ignoreValidators): [PolymorphicSubtypesRule] properties: name: type: string diff --git a/api-specs/api/types/search/SearchCompoundExpression.raml b/api-specs/api/types/search/SearchCompoundExpression.raml index 7c7b3d19a..643a2dbd5 100644 --- a/api-specs/api/types/search/SearchCompoundExpression.raml +++ b/api-specs/api/types/search/SearchCompoundExpression.raml @@ -3,3 +3,4 @@ type: SearchQuery (beta): true displayName: SearchCompoundExpression +(ignoreValidators): [PolymorphicSubtypesRule] diff --git a/api-specs/api/types/search/SearchQuery.raml b/api-specs/api/types/search/SearchQuery.raml index d8572b41a..41c39166e 100644 --- a/api-specs/api/types/search/SearchQuery.raml +++ b/api-specs/api/types/search/SearchQuery.raml @@ -3,3 +3,4 @@ type: object (beta): true displayName: SearchQuery +(ignoreValidators): [PolymorphicSubtypesRule] diff --git a/api-specs/api/types/search/SearchQueryExpression.raml b/api-specs/api/types/search/SearchQueryExpression.raml index 4c5288f77..5b8018d57 100644 --- a/api-specs/api/types/search/SearchQueryExpression.raml +++ b/api-specs/api/types/search/SearchQueryExpression.raml @@ -3,3 +3,4 @@ type: SearchQuery (beta): true displayName: SearchQueryExpression +(ignoreValidators): [PolymorphicSubtypesRule] diff --git a/api-specs/api/types/search/SearchQueryExpressionValue.raml b/api-specs/api/types/search/SearchQueryExpressionValue.raml index 80942d0e9..fff35d97c 100644 --- a/api-specs/api/types/search/SearchQueryExpressionValue.raml +++ b/api-specs/api/types/search/SearchQueryExpressionValue.raml @@ -3,6 +3,7 @@ type: object (beta): true displayName: SearchQueryExpressionValue +(ignoreValidators): [PolymorphicSubtypesRule] properties: field: type: string diff --git a/api-specs/readme.md b/api-specs/readme.md index fd585f5fe..881603e00 100644 --- a/api-specs/readme.md +++ b/api-specs/readme.md @@ -700,6 +700,10 @@ This annotation is declared on the API settings level, so in the [api-specs/api/ Use this annotation to add descriptions to an enum property, like here [ChannelRoleEnum.raml](./api/types/channel/ChannelRoleEnum.raml). +##### (ignoreValidators) + +Use this annotation to ignore the rules in this list for the specific type, resource or module. + ### Composable Commerce API folder structure #### /examples @@ -1314,6 +1318,32 @@ resourceTypes: get: ``` +#### PolymorphicSubtypesRule + +The rule verifies that a type defines a discriminator if it has subtypes to avoid issues with deserialization of read models. + +```raml +types: + Foo: + type: object + discriminator: type + properties: + type: string + SubFoo: + discriminatorValue: sub + type: Foo + InvalidBar: + type: object + description: InvalidBar + properties: + name: string + SubBar: + description: SubBar + type: InvalidBar + SubBar2: + type: InvalidBar +``` + # Generate a Postman Collection Follow the steps in the [Generate a Postman Collection](https://github.com/commercetools/commercetools-docs/blob/main/api-specs/generate-a-postman-collection.md) guide to learn more.