chore(oas): [12/n] improve oas schemas (#9200)

- improve OAS schemas [12/n]
- Support ignoring properties in type if it has the `@ignore` jsdoc tag.
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-09-19 14:25:16 +00:00
1 parent 89928dfdf3
commit 4923a6e823
20 files changed
+287 -149

No files matched your search

@@ -2,16 +2,15 @@
* @oas [get] /admin/promotions/rule-attribute-options/{rule_type} * @oas [get] /admin/promotions/rule-attribute-options/{rule_type}
* operationId: GetPromotionsRuleAttributeOptionsRule_type * operationId: GetPromotionsRuleAttributeOptionsRule_type
* summary: List Rule Attribute Options of a Rule Type * summary: List Rule Attribute Options of a Rule Type
* x-sidebar-summary: List Rule Attribute Options * x-sidebar-summary: List Potential Rule Attributes
* description: > * description: |
* Retrieve a list of attributes for the promotion and application method types specified in the query parameters. * Retrieve a list of potential rule attributes for the promotion and application method types specified in the query parameters.
*
* Only the attributes of the rule type specified in the path parameter are retrieved: * Only the attributes of the rule type specified in the path parameter are retrieved:
*
* - If `rule_type` is `rules`, the attributes of the promotion's type are retrieved. * - If `rule_type` is `rules`, the attributes of the promotion's type are retrieved.
* *
* * - If `rule_type` is `target-rules`, the target rules' attributes of the application method's type are retrieved.
* - If `rule_type` is `target-rules`, the target rules' attributes of the application method's type are retrieved. - If `rule_type` is `buy-rules`, the buy rules' attributes of the application method's type are retrieved. *
* - If `rule_type` is `buy-rules`, the buy rules' attributes of the application method's type are retrieved.
* x-authenticated: true * x-authenticated: true
* parameters: * parameters:
* - name: rule_type * - name: rule_type
@@ -4,86 +4,22 @@
* description: The shipping option's details. * description: The shipping option's details.
* x-schemaName: AdminCreateShippingOption * x-schemaName: AdminCreateShippingOption
* required: * required:
* - name * - label
* - service_zone_id * - description
* - shipping_profile_id * - code
* - price_type
* - provider_id
* - type
* - prices
* properties: * properties:
* name: * label:
* type: string * type: string
* title: name * title: label
* description: The shipping option's name. * description: The type's label.
* service_zone_id: * description:
* type: string * type: string
* title: service_zone_id * title: description
* description: The ID of the service zone this shipping option belongs to. * description: The type's description.
* shipping_profile_id: * code:
* type: string * type: string
* title: shipping_profile_id * title: code
* description: The ID of the shipping profile this shipping option belongs to. * description: The type's code.
* data:
* type: object
* description: Any data necessary for fulfillment providers to handle shipping methods and fulfillments of this shipping option.
* externalDocs:
* url: https://docs.medusajs.com/v2/resources/commerce-modules/fulfillment/shipping-option#data-property
* description: Learn more about the data property.
* price_type:
* type: string
* description: >
* The shipping option price's type. If `flat`, it means the option has a fixed price set in the `prices` property.
* `calculated` means that the shipping option's price is calculated during checkout.
* enum:
* - flat
* - calculated
* provider_id:
* type: string
* title: provider_id
* description: The ID of the fulfillment provider used to handle this shipping option and its associated methods and fulfillments.
* type:
* $ref: "#/components/schemas/AdminCreateShippingOption"
* prices:
* type: array
* description: The shipping option's prices. If `price_type` is `calculated`, pass an empty array for this property.
* items:
* oneOf:
* - type: object
* description: The price for a currency code.
* x-schemaName: AdminCreateShippingOptionPriceWithCurrency
* required:
* - currency_code
* - amount
* properties:
* currency_code:
* type: string
* title: currency_code
* description: The price's currency code.
* amount:
* type: number
* title: amount
* description: The price's amount.
* - type: object
* description: The price in a region.
* x-schemaName: AdminCreateShippingOptionPriceWithRegion
* required:
* - region_id
* - amount
* properties:
* region_id:
* type: string
* title: region_id
* description: The ID of the region this price is used in.
* amount:
* type: number
* title: amount
* description: The price's amount.
* rules:
* type: array
* description: The shipping option's rules.
* items:
* $ref: "#/components/schemas/AdminCreateShippingOptionRule"
* *
*/ */
@@ -3,6 +3,18 @@
* type: object * type: object
* description: The shipping option's provider. * description: The shipping option's provider.
* x-schemaName: AdminFulfillmentProvider * x-schemaName: AdminFulfillmentProvider
* required:
* - id
* - is_enabled
* properties:
* id:
* type: string
* title: id
* description: The provider's ID.
* is_enabled:
* type: boolean
* title: is_enabled
* description: The provider's is enabled.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminFulfillmentSet * @schema AdminFulfillmentSet
* type: object * type: object
* description: The fulfillment set's parent. * description: The service zone's fulfillment set.
* x-schemaName: AdminFulfillmentSet * x-schemaName: AdminFulfillmentSet
* required: * required:
* - id * - id
@@ -16,37 +16,37 @@
* id: * id:
* type: string * type: string
* title: id * title: id
* description: The parent's ID. * description: The fulfillment set's ID.
* name: * name:
* type: string * type: string
* title: name * title: name
* description: The parent's name. * description: The fulfillment set's name.
* type: * type:
* type: string * type: string
* title: type * title: type
* description: The parent's type. * description: The fulfillment set's type.
* location: * location:
* $ref: "#/components/schemas/AdminStockLocation" * $ref: "#/components/schemas/AdminStockLocation"
* service_zones: * service_zones:
* type: array * type: array
* description: The parent's service zones. * description: The fulfillment set's service zones.
* items: * items:
* $ref: "#/components/schemas/AdminServiceZone" * $ref: "#/components/schemas/AdminServiceZone"
* created_at: * created_at:
* type: string * type: string
* format: date-time * format: date-time
* title: created_at * title: created_at
* description: The parent's created at. * description: The fulfillment set's created at.
* updated_at: * updated_at:
* type: string * type: string
* format: date-time * format: date-time
* title: updated_at * title: updated_at
* description: The parent's updated at. * description: The fulfillment set's updated at.
* deleted_at: * deleted_at:
* type: string * type: string
* format: date-time * format: date-time
* title: deleted_at * title: deleted_at
* description: The parent's deleted at. * description: The fulfillment set's deleted at.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminGeoZone * @schema AdminGeoZone
* type: object * type: object
* description: The geo zone's details. * description: The geo zone's geo zones.
* x-schemaName: AdminGeoZone * x-schemaName: AdminGeoZone
* required: * required:
* - id * - id
@@ -45,17 +45,17 @@
* type: string * type: string
* format: date-time * format: date-time
* title: created_at * title: created_at
* description: The date the geo zone was created. * description: The geo zone's created at.
* updated_at: * updated_at:
* type: string * type: string
* format: date-time * format: date-time
* title: updated_at * title: updated_at
* description: The date the geo zone was update. * description: The geo zone's updated at.
* deleted_at: * deleted_at:
* type: string * type: string
* format: date-time * format: date-time
* title: deleted_at * title: deleted_at
* description: The date the geo zone was deleted. * description: The geo zone's deleted at.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminRuleAttributeOption * @schema AdminRuleAttributeOption
* type: object * type: object
* description: The attribute's attributes. * description: The details of a potential rule attribute.
* x-schemaName: AdminRuleAttributeOption * x-schemaName: AdminRuleAttributeOption
* required: * required:
* - id * - id
@@ -9,33 +9,23 @@
* - label * - label
* - field_type * - field_type
* - required * - required
* - disguised
* - operators * - operators
* properties: * properties:
* id: * id:
* type: string * type: string
* title: id * title: id
* description: The attribute's ID. * description: The rule attribute's ID, which is a rule's `attribute` it refers to.
* example: "customer_group"
* value: * value:
* type: string * type: string
* title: value * title: value
* description: The attribute's value. * description: The rule attribute's value.
* example: "customer.groups.id"
* label: * label:
* type: string * type: string
* title: label * title: label
* description: The attribute's label. * description: The rule attribute option's label.
* field_type: * example: "Customer Group"
* type: string
* title: field_type
* description: The attribute's field type.
* required:
* type: boolean
* title: required
* description: The attribute's required.
* disguised:
* type: boolean
* title: disguised
* description: The attribute's disguised.
* operators: * operators:
* type: array * type: array
* description: The attribute's operators. * description: The attribute's operators.
@@ -1,25 +1,22 @@
/** /**
* @schema AdminRuleValueOption * @schema AdminRuleValueOption
* type: object * type: object
* description: The value's values. * description: The details of a potential rule value.
* x-schemaName: AdminRuleValueOption * x-schemaName: AdminRuleValueOption
* required: * required:
* - id
* - value * - value
* - label * - label
* properties: * properties:
* id:
* type: string
* title: id
* description: The value's ID.
* value: * value:
* type: string * type: string
* title: value * title: value
* description: The value's details. * description: The rule value's value.
* example: "reg_123"
* label: * label:
* type: string * type: string
* title: label * title: label
* description: The value's label. * description: The rule value's label.
* example: "Europe Region"
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminSalesChannel * @schema AdminSalesChannel
* type: object * type: object
* description: The order's sales channel. * description: The sales channel's details.
* x-schemaName: AdminSalesChannel * x-schemaName: AdminSalesChannel
* required: * required:
* - id * - id
@@ -28,25 +28,25 @@
* is_disabled: * is_disabled:
* type: boolean * type: boolean
* title: is_disabled * title: is_disabled
* description: The sales channel's is disabled. * description: Whether the sales channel is disabled.
* metadata: * metadata:
* type: object * type: object
* description: The sales channel's metadata. * description: The sales channel's metadata, can hold custom key-value pairs.
* created_at: * created_at:
* type: string * type: string
* format: date-time * format: date-time
* title: created_at * title: created_at
* description: The sales channel's created at. * description: The date the sales channel was created.
* updated_at: * updated_at:
* type: string * type: string
* format: date-time * format: date-time
* title: updated_at * title: updated_at
* description: The sales channel's updated at. * description: The date the sales channel was updated.
* deleted_at: * deleted_at:
* type: string * type: string
* format: date-time * format: date-time
* title: deleted_at * title: deleted_at
* description: The sales channel's deleted at. * description: The date the sales channel was deleted.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminSalesChannelDeleteResponse * @schema AdminSalesChannelDeleteResponse
* type: object * type: object
* description: SUMMARY * description: The details of deleting a sales channel.
* x-schemaName: AdminSalesChannelDeleteResponse * x-schemaName: AdminSalesChannelDeleteResponse
* required: * required:
* - id * - id
@@ -20,7 +20,7 @@
* deleted: * deleted:
* type: boolean * type: boolean
* title: deleted * title: deleted
* description: Whether the Sales Channel was deleted. * description: Whether the sales channel was deleted.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminSalesChannelResponse * @schema AdminSalesChannelResponse
* type: object * type: object
* description: SUMMARY * description: The sales channel's details.
* x-schemaName: AdminSalesChannelResponse * x-schemaName: AdminSalesChannelResponse
* required: * required:
* - sales_channel * - sales_channel
@@ -1,7 +1,7 @@
/** /**
* @schema AdminServiceZone * @schema AdminServiceZone
* type: object * type: object
* description: The service zone's service zones. * description: The shipping option's service zone.
* x-schemaName: AdminServiceZone * x-schemaName: AdminServiceZone
* required: * required:
* - id * - id
@@ -1,7 +1,7 @@
/** /**
* @schema AdminServiceZoneDeleteResponse * @schema AdminServiceZoneDeleteResponse
* type: object * type: object
* description: SUMMARY * description: The details of the service zone deletion.
* x-schemaName: AdminServiceZoneDeleteResponse * x-schemaName: AdminServiceZoneDeleteResponse
* required: * required:
* - id * - id
@@ -11,15 +11,16 @@
* id: * id:
* type: string * type: string
* title: id * title: id
* description: The fulfillment set's ID. * description: The service zone's ID.
* object: * object:
* type: string * type: string
* title: object * title: object
* description: The name of the deleted object. * description: The name of the deleted object.
* default: "service_zone"
* deleted: * deleted:
* type: boolean * type: boolean
* title: deleted * title: deleted
* description: Whether the Fulfillment Set was deleted. * description: Whether the service zone was deleted.
* parent: * parent:
* $ref: "#/components/schemas/AdminFulfillmentSet" * $ref: "#/components/schemas/AdminFulfillmentSet"
* *
@@ -1,7 +1,7 @@
/** /**
* @schema AdminServiceZoneResponse * @schema AdminServiceZoneResponse
* type: object * type: object
* description: SUMMARY * description: The service zone's details.
* x-schemaName: AdminServiceZoneResponse * x-schemaName: AdminServiceZoneResponse
* required: * required:
* - service_zone * - service_zone
@@ -1,8 +1,99 @@
/** /**
* @schema AdminShippingOption * @schema AdminShippingOption
* type: object * type: object
* description: The shipping option's shipping options. * description: The shipping option's details.
* x-schemaName: AdminShippingOption * x-schemaName: AdminShippingOption
* required:
* - id
* - name
* - price_type
* - service_zone_id
* - service_zone
* - provider_id
* - provider
* - shipping_option_type_id
* - type
* - shipping_profile_id
* - shipping_profile
* - rules
* - prices
* - data
* - metadata
* - created_at
* - updated_at
* - deleted_at
* properties:
* id:
* type: string
* title: id
* description: The shipping option's ID.
* name:
* type: string
* title: name
* description: The shipping option's name.
* price_type:
* type: string
* description: The shipping option's price type. If it's `flat`, the price is fixed and is set in the `prices` property. If it's `calculated`, the price is calculated on checkout by the associated fulfillment provider.
* enum:
* - calculated
* - flat
* service_zone_id:
* type: string
* title: service_zone_id
* description: The ID of the service zone this option belongs to.
* service_zone:
* $ref: "#/components/schemas/AdminServiceZone"
* provider_id:
* type: string
* title: provider_id
* description: The ID of the provider handling fulfillments created from this shipping option.
* provider:
* $ref: "#/components/schemas/AdminFulfillmentProvider"
* shipping_option_type_id:
* type: string
* title: shipping_option_type_id
* description: The ID of the associated shipping option type.
* type:
* $ref: "#/components/schemas/AdminShippingOption"
* shipping_profile_id:
* type: string
* title: shipping_profile_id
* description: The ID of the associated shipping profile.
* shipping_profile:
* $ref: "#/components/schemas/AdminShippingProfile"
* rules:
* type: array
* description: The shipping option's rules.
* items:
* $ref: "#/components/schemas/AdminShippingOptionRule"
* prices:
* type: array
* description: The shipping option's prices. If the `price_type` is `calculated`, this array will be empty since the price is calculated by the fulfillment provider during checkout.
* items:
* $ref: "#/components/schemas/AdminShippingOptionPrice"
* data:
* type: object
* description: The shipping option's data, useful for the fulfillment provider handling fulfillments created from this option.
* externalDocs:
* url: https://docs.medusajs.com/v2/resources/commerce-modules/fulfillment/shipping-option#data-property
* metadata:
* type: object
* description: The shipping option's metadata, can hold custom key-value pairs.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the shipping option was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the shipping option was updated.
* deleted_at:
* type: string
* format: date-time
* title: deleted_at
* description: The date the shipping option was deleted.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminShippingOptionDeleteResponse * @schema AdminShippingOptionDeleteResponse
* type: object * type: object
* description: SUMMARY * description: The details of the shipping option's deletion.
* x-schemaName: AdminShippingOptionDeleteResponse * x-schemaName: AdminShippingOptionDeleteResponse
* required: * required:
* - id * - id
@@ -20,7 +20,7 @@
* deleted: * deleted:
* type: boolean * type: boolean
* title: deleted * title: deleted
* description: Whether the Shipping Option was deleted. * description: Whether the shipping option was deleted.
* *
*/ */
@@ -0,0 +1,79 @@
/**
* @schema AdminShippingOptionPrice
* type: object
* description: The details of the shipping option's price.
* x-schemaName: AdminShippingOptionPrice
* required:
* - price_rules
* - rules_count
* - id
* - title
* - currency_code
* - amount
* - raw_amount
* - min_quantity
* - max_quantity
* - price_set_id
* - created_at
* - updated_at
* - deleted_at
* properties:
* price_rules:
* type: array
* description: The price's rules.
* items:
* $ref: "#/components/schemas/AdminShippingOptionPriceRule"
* rules_count:
* type: number
* title: rules_count
* description: The number of rules the price has.
* id:
* type: string
* title: id
* description: The price's ID.
* title:
* type: string
* title: title
* description: The price's title.
* currency_code:
* type: string
* title: currency_code
* description: The price's currency code.
* example: usd
* amount:
* type: number
* title: amount
* description: The price's amount.
* raw_amount:
* type: object
* description: The price's raw amount.
* min_quantity:
* type: number
* title: min_quantity
* description: The minimum quantity required in the cart for this price to apply.
* max_quantity:
* type: number
* title: max_quantity
* description: The maximum quantity that the cart's items must not surpass for this price to apply.
* price_set_id:
* type: string
* title: price_set_id
* description: The ID of the price set this price belongs to.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the price was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the price was updated.
* deleted_at:
* type: string
* format: date-time
* title: deleted_at
* description: The date the price was deleted.
*
*/
@@ -0,0 +1,20 @@
/**
* @schema AdminShippingOptionPriceRule
* type: object
* description: The details of a shipping option price's rule.
* x-schemaName: AdminShippingOptionPriceRule
* required:
* - id
* - value
* properties:
* id:
* type: string
* title: id
* description: The price rule's ID.
* value:
* type: string
* title: value
* description: The price rule's value.
*
*/
@@ -1,7 +1,7 @@
/** /**
* @schema AdminShippingOptionResponse * @schema AdminShippingOptionResponse
* type: object * type: object
* description: SUMMARY * description: The shipping option's details.
* x-schemaName: AdminShippingOptionResponse * x-schemaName: AdminShippingOptionResponse
* required: * required:
* - shipping_option * - shipping_option
@@ -1,7 +1,7 @@
/** /**
* @schema AdminShippingOptionRule * @schema AdminShippingOptionRule
* type: object * type: object
* description: The updated's details. * description: The shipping option rule's details.
* x-schemaName: AdminShippingOptionRule * x-schemaName: AdminShippingOptionRule
* required: * required:
* - id * - id
@@ -16,45 +16,49 @@
* id: * id:
* type: string * type: string
* title: id * title: id
* description: The updated's ID. * description: The shipping option rule's ID.
* attribute: * attribute:
* type: string * type: string
* title: attribute * title: attribute
* description: The updated's attribute. * description: The shipping option rule's attribute.
* example: is_return
* operator: * operator:
* type: string * type: string
* title: operator * title: operator
* description: The updated's operator. * description: The shipping option rule's operator.
* example: eq
* value: * value:
* oneOf: * oneOf:
* - type: string * - type: string
* title: value * title: value
* description: The updated's value. * description: The rule's value.
* example: '"true"'
* - type: array * - type: array
* description: The updated's value. * description: The rule's values.
* items: * items:
* type: string * type: string
* title: value * title: value
* description: The value's details. * description: A rule's value
* example: '"true"'
* shipping_option_id: * shipping_option_id:
* type: string * type: string
* title: shipping_option_id * title: shipping_option_id
* description: The updated's shipping option id. * description: The ID of the shipping option this rule is for.
* created_at: * created_at:
* type: string * type: string
* format: date-time * format: date-time
* title: created_at * title: created_at
* description: The updated's created at. * description: The date the shipping option rule was created.
* updated_at: * updated_at:
* type: string * type: string
* format: date-time * format: date-time
* title: updated_at * title: updated_at
* description: The updated's updated at. * description: The date the shipping option rule was updated.
* deleted_at: * deleted_at:
* type: string * type: string
* format: date-time * format: date-time
* title: deleted_at * title: deleted_at
* description: The updated's deleted at. * description: The date the shipping option rule was deleted.
* *
*/ */
@@ -1543,6 +1543,15 @@ class OasKindGenerator extends FunctionKindGenerator {
) { ) {
return return
} }
const shouldIgnore = property
.getJsDocTags()
.some((tag) => tag.name === "ignore")
if (shouldIgnore) {
return
}
if (this.isRequired(property)) { if (this.isRequired(property)) {
requiredProperties.push(property.name) requiredProperties.push(property.name)
} }