docs-util: fixes to OAS generator + generate OAS (#10867)

This commit is contained in:
Shahed Nasser
2025-01-07 16:35:55 +02:00
committed by GitHub
parent 899b1fba4a
commit edcff0ed16
19 changed files with 152 additions and 18 deletions
@@ -5,6 +5,7 @@ required:
- payment_collections - payment_collections
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- version - version
@@ -235,3 +236,7 @@ properties:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
@@ -6,6 +6,7 @@ x-schemaName: AdminOrderPreview
required: required:
- return_requested_total - return_requested_total
- order_change - order_change
- status
- currency_code - currency_code
- id - id
- version - version
@@ -643,3 +644,7 @@ properties:
$ref: ./AdminCustomer.yaml $ref: ./AdminCustomer.yaml
sales_channel: sales_channel:
$ref: ./AdminSalesChannel.yaml $ref: ./AdminSalesChannel.yaml
status:
type: string
title: status
description: The order's status.
@@ -9,6 +9,7 @@ required:
- sales_channel_id - sales_channel_id
- email - email
- currency_code - currency_code
- status
- items - items
- shipping_methods - shipping_methods
- payment_status - payment_status
@@ -230,3 +231,7 @@ properties:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
@@ -4,6 +4,7 @@ x-schemaName: StoreOrder
required: required:
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- region_id - region_id
@@ -228,3 +229,7 @@ properties:
description: The order's transactions. description: The order's transactions.
items: items:
$ref: ./BaseOrderTransaction.yaml $ref: ./BaseOrderTransaction.yaml
status:
type: string
title: status
description: The order's status.
@@ -43329,7 +43329,10 @@ paths:
schema: schema:
type: object type: object
title: input title: input
description: The input data necessary for authentication. For example, for email-pass authentication, pass `email` and `password` properties. description: |
The input data necessary for authentication.
For example, for email-pass authentication, pass `email` and `password` properties.
For the Google and GitHub authentication providers, you can pass `callback_url` to indicate the URL in the frontend that the user should be redirected to after completing their authentication. This will override the provider's `callbackUrl` configurations in `medusa-config.ts`.
x-codeSamples: x-codeSamples:
- lang: Shell - lang: Shell
label: EmailPass Provider label: EmailPass Provider
@@ -47909,6 +47912,7 @@ components:
- payment_collections - payment_collections
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- version - version
@@ -48139,6 +48143,10 @@ components:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
AdminOrderAddress: AdminOrderAddress:
type: object type: object
description: An order address. description: An order address.
@@ -48830,6 +48838,7 @@ components:
required: required:
- return_requested_total - return_requested_total
- order_change - order_change
- status
- currency_code - currency_code
- id - id
- version - version
@@ -49441,6 +49450,10 @@ components:
$ref: '#/components/schemas/AdminCustomer' $ref: '#/components/schemas/AdminCustomer'
sales_channel: sales_channel:
$ref: '#/components/schemas/AdminSalesChannel' $ref: '#/components/schemas/AdminSalesChannel'
status:
type: string
title: status
description: The order's status.
AdminOrderPreviewResponse: AdminOrderPreviewResponse:
type: object type: object
description: The preview of an order. description: The preview of an order.
@@ -55927,6 +55940,7 @@ components:
- sales_channel_id - sales_channel_id
- email - email
- currency_code - currency_code
- status
- items - items
- shipping_methods - shipping_methods
- payment_status - payment_status
@@ -56148,6 +56162,10 @@ components:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
BaseOrderAddress: BaseOrderAddress:
type: object type: object
description: An order address. description: An order address.
@@ -62108,6 +62126,7 @@ components:
required: required:
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- region_id - region_id
@@ -62332,6 +62351,10 @@ components:
description: The order's transactions. description: The order's transactions.
items: items:
$ref: '#/components/schemas/BaseOrderTransaction' $ref: '#/components/schemas/BaseOrderTransaction'
status:
type: string
title: status
description: The order's status.
StoreOrderAddress: StoreOrderAddress:
type: object type: object
description: An order address description: An order address
@@ -28,9 +28,17 @@ post:
schema: schema:
type: object type: object
title: input title: input
description: >- description: >
The input data necessary for authentication. For example, for The input data necessary for authentication.
email-pass authentication, pass `email` and `password` properties.
For example, for email-pass authentication, pass `email` and
`password` properties.
For the Google and GitHub authentication providers, you can pass
`callback_url` to indicate the URL in the frontend that the user
should be redirected to after completing their authentication. This
will override the provider's `callbackUrl` configurations in
`medusa-config.ts`.
x-codeSamples: x-codeSamples:
- lang: Shell - lang: Shell
label: EmailPass Provider label: EmailPass Provider
@@ -5,6 +5,7 @@ required:
- payment_collections - payment_collections
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- version - version
@@ -235,3 +236,7 @@ properties:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
@@ -6,6 +6,7 @@ x-schemaName: AdminOrderPreview
required: required:
- return_requested_total - return_requested_total
- order_change - order_change
- status
- currency_code - currency_code
- id - id
- version - version
@@ -643,3 +644,7 @@ properties:
$ref: ./AdminCustomer.yaml $ref: ./AdminCustomer.yaml
sales_channel: sales_channel:
$ref: ./AdminSalesChannel.yaml $ref: ./AdminSalesChannel.yaml
status:
type: string
title: status
description: The order's status.
@@ -9,6 +9,7 @@ required:
- sales_channel_id - sales_channel_id
- email - email
- currency_code - currency_code
- status
- items - items
- shipping_methods - shipping_methods
- payment_status - payment_status
@@ -230,3 +231,7 @@ properties:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
@@ -4,6 +4,7 @@ x-schemaName: StoreOrder
required: required:
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- region_id - region_id
@@ -228,3 +229,7 @@ properties:
description: The order's transactions. description: The order's transactions.
items: items:
$ref: ./BaseOrderTransaction.yaml $ref: ./BaseOrderTransaction.yaml
status:
type: string
title: status
description: The order's status.
@@ -174,7 +174,10 @@ paths:
schema: schema:
type: object type: object
title: input title: input
description: The input data necessary for authentication. For example, for email-pass authentication, pass `email` and `password` properties. description: |
The input data necessary for authentication.
For example, for email-pass authentication, pass `email` and `password` properties.
For the Google and GitHub authentication providers, you can pass `callback_url` to indicate the URL in the frontend that the customer should be redirected to after completing their authentication. This will override the provider's `callbackUrl` configurations in `medusa-config.ts`.
x-codeSamples: x-codeSamples:
- lang: Shell - lang: Shell
label: EmailPass Provider label: EmailPass Provider
@@ -10530,6 +10533,7 @@ components:
- payment_collections - payment_collections
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- version - version
@@ -10760,6 +10764,10 @@ components:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
AdminOrderAddress: AdminOrderAddress:
type: object type: object
description: An order address. description: An order address.
@@ -11451,6 +11459,7 @@ components:
required: required:
- return_requested_total - return_requested_total
- order_change - order_change
- status
- currency_code - currency_code
- id - id
- version - version
@@ -12062,6 +12071,10 @@ components:
$ref: '#/components/schemas/AdminCustomer' $ref: '#/components/schemas/AdminCustomer'
sales_channel: sales_channel:
$ref: '#/components/schemas/AdminSalesChannel' $ref: '#/components/schemas/AdminSalesChannel'
status:
type: string
title: status
description: The order's status.
AdminOrderPreviewResponse: AdminOrderPreviewResponse:
type: object type: object
description: The preview of an order. description: The preview of an order.
@@ -18548,6 +18561,7 @@ components:
- sales_channel_id - sales_channel_id
- email - email
- currency_code - currency_code
- status
- items - items
- shipping_methods - shipping_methods
- payment_status - payment_status
@@ -18769,6 +18783,10 @@ components:
type: number type: number
title: original_shipping_tax_total title: original_shipping_tax_total
description: The tax total of the order's shipping excluding promotions. description: The tax total of the order's shipping excluding promotions.
status:
type: string
title: status
description: The order's status.
BaseOrderAddress: BaseOrderAddress:
type: object type: object
description: An order address. description: An order address.
@@ -24729,6 +24747,7 @@ components:
required: required:
- items - items
- shipping_methods - shipping_methods
- status
- currency_code - currency_code
- id - id
- region_id - region_id
@@ -24953,6 +24972,10 @@ components:
description: The order's transactions. description: The order's transactions.
items: items:
$ref: '#/components/schemas/BaseOrderTransaction' $ref: '#/components/schemas/BaseOrderTransaction'
status:
type: string
title: status
description: The order's status.
StoreOrderAddress: StoreOrderAddress:
type: object type: object
description: An order address description: An order address
@@ -28,9 +28,17 @@ post:
schema: schema:
type: object type: object
title: input title: input
description: >- description: >
The input data necessary for authentication. For example, for The input data necessary for authentication.
email-pass authentication, pass `email` and `password` properties.
For example, for email-pass authentication, pass `email` and
`password` properties.
For the Google and GitHub authentication providers, you can pass
`callback_url` to indicate the URL in the frontend that the customer
should be redirected to after completing their authentication. This
will override the provider's `callbackUrl` configurations in
`medusa-config.ts`.
x-codeSamples: x-codeSamples:
- lang: Shell - lang: Shell
label: EmailPass Provider label: EmailPass Provider
@@ -26,7 +26,12 @@
* schema: * schema:
* type: object * type: object
* title: input * title: input
* description: The input data necessary for authentication. For example, for email-pass authentication, pass `email` and `password` properties. * description: >
* The input data necessary for authentication.
*
* For example, for email-pass authentication, pass `email` and `password` properties.
*
* For the Google and GitHub authentication providers, you can pass `callback_url` to indicate the URL in the frontend that the user should be redirected to after completing their authentication. This will override the provider's `callbackUrl` configurations in `medusa-config.ts`.
* x-codeSamples: * x-codeSamples:
* - lang: Shell * - lang: Shell
* label: EmailPass Provider * label: EmailPass Provider
@@ -26,7 +26,12 @@
* schema: * schema:
* type: object * type: object
* title: input * title: input
* description: The input data necessary for authentication. For example, for email-pass authentication, pass `email` and `password` properties. * description: >
* The input data necessary for authentication.
*
* For example, for email-pass authentication, pass `email` and `password` properties.
*
* For the Google and GitHub authentication providers, you can pass `callback_url` to indicate the URL in the frontend that the customer should be redirected to after completing their authentication. This will override the provider's `callbackUrl` configurations in `medusa-config.ts`.
* x-codeSamples: * x-codeSamples:
* - lang: Shell * - lang: Shell
* label: EmailPass Provider * label: EmailPass Provider
@@ -7,6 +7,7 @@
* - payment_collections * - payment_collections
* - items * - items
* - shipping_methods * - shipping_methods
* - status
* - currency_code * - currency_code
* - id * - id
* - version * - version
@@ -237,6 +238,10 @@
* type: number * type: number
* title: original_shipping_tax_total * title: original_shipping_tax_total
* description: The tax total of the order's shipping excluding promotions. * description: The tax total of the order's shipping excluding promotions.
* status:
* type: string
* title: status
* description: The order's status.
* *
*/ */
@@ -6,6 +6,7 @@
* required: * required:
* - return_requested_total * - return_requested_total
* - order_change * - order_change
* - status
* - currency_code * - currency_code
* - id * - id
* - version * - version
@@ -617,6 +618,10 @@
* $ref: "#/components/schemas/AdminCustomer" * $ref: "#/components/schemas/AdminCustomer"
* sales_channel: * sales_channel:
* $ref: "#/components/schemas/AdminSalesChannel" * $ref: "#/components/schemas/AdminSalesChannel"
* status:
* type: string
* title: status
* description: The order's status.
* *
*/ */
@@ -11,6 +11,7 @@
* - sales_channel_id * - sales_channel_id
* - email * - email
* - currency_code * - currency_code
* - status
* - items * - items
* - shipping_methods * - shipping_methods
* - payment_status * - payment_status
@@ -232,6 +233,10 @@
* type: number * type: number
* title: original_shipping_tax_total * title: original_shipping_tax_total
* description: The tax total of the order's shipping excluding promotions. * description: The tax total of the order's shipping excluding promotions.
* status:
* type: string
* title: status
* description: The order's status.
* *
*/ */
@@ -6,6 +6,7 @@
* required: * required:
* - items * - items
* - shipping_methods * - shipping_methods
* - status
* - currency_code * - currency_code
* - id * - id
* - region_id * - region_id
@@ -230,6 +231,10 @@
* description: The order's transactions. * description: The order's transactions.
* items: * items:
* $ref: "#/components/schemas/BaseOrderTransaction" * $ref: "#/components/schemas/BaseOrderTransaction"
* status:
* type: string
* title: status
* description: The order's status.
* *
*/ */
@@ -483,7 +483,7 @@ class OasKindGenerator extends FunctionKindGenerator {
oas.parameters = this.updateParameters({ oas.parameters = this.updateParameters({
oldParameters: oas.parameters as OpenAPIV3.ParameterObject[], oldParameters: oas.parameters as OpenAPIV3.ParameterObject[],
newParameters: newPathParameters, newParameters: newPathParameters,
type: "path", types: ["path", "header"],
}) })
// retrieve updated query and request schemas // retrieve updated query and request schemas
@@ -498,7 +498,7 @@ class OasKindGenerator extends FunctionKindGenerator {
oas.parameters = this.updateParameters({ oas.parameters = this.updateParameters({
oldParameters: oas.parameters as OpenAPIV3.ParameterObject[], oldParameters: oas.parameters as OpenAPIV3.ParameterObject[],
newParameters: queryParameters, newParameters: queryParameters,
type: "query", types: ["query"],
}) })
if (!oas.parameters.length) { if (!oas.parameters.length) {
@@ -1913,7 +1913,7 @@ class OasKindGenerator extends FunctionKindGenerator {
updateParameters({ updateParameters({
oldParameters, oldParameters,
newParameters, newParameters,
type, types,
}: { }: {
/** /**
* The old list of parameters. * The old list of parameters.
@@ -1926,13 +1926,13 @@ class OasKindGenerator extends FunctionKindGenerator {
/** /**
* The type of parameters. * The type of parameters.
*/ */
type: ParameterType types: ParameterType[]
}): OpenAPIV3.ParameterObject[] { }): OpenAPIV3.ParameterObject[] {
if (!oldParameters) { if (!oldParameters) {
return newParameters || [] return newParameters || []
} }
const oppositeParamType = ["path", "query", "header"].filter( const oppositeParamType = ["path", "query", "header"].filter(
(item) => item !== type (item) => !types.includes(item as ParameterType)
) as ParameterType[] ) as ParameterType[]
const oppositeParams: OpenAPIV3.ParameterObject[] = const oppositeParams: OpenAPIV3.ParameterObject[] =
oldParameters?.filter((param) => oldParameters?.filter((param) =>
@@ -1940,7 +1940,9 @@ class OasKindGenerator extends FunctionKindGenerator {
) || [] ) || []
// check and update/add parameters if necessary // check and update/add parameters if necessary
const existingParams: OpenAPIV3.ParameterObject[] = const existingParams: OpenAPIV3.ParameterObject[] =
oldParameters?.filter((param) => param.in === type) || [] oldParameters?.filter((param) =>
types.includes(param.in as ParameterType)
) || []
const paramsToRemove = new Set<string>() const paramsToRemove = new Set<string>()
existingParams.forEach((parameter) => { existingParams.forEach((parameter) => {
@@ -2405,8 +2407,8 @@ class OasKindGenerator extends FunctionKindGenerator {
const fnText = node.getText() const fnText = node.getText()
return { return {
shouldAddFields: fnText.includes(`req.remoteQueryConfig.fields`), shouldAddFields: fnText.includes(`req.queryConfig.fields`),
shouldAddPagination: fnText.includes(`req.remoteQueryConfig.pagination`), shouldAddPagination: fnText.includes(`req.queryConfig.pagination`),
} }
} }