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
@@ -26,7 +26,12 @@
* schema:
* type: object
* 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:
* - lang: Shell
* label: EmailPass Provider
@@ -26,7 +26,12 @@
* schema:
* type: object
* 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:
* - lang: Shell
* label: EmailPass Provider
@@ -7,6 +7,7 @@
* - payment_collections
* - items
* - shipping_methods
* - status
* - currency_code
* - id
* - version
@@ -237,6 +238,10 @@
* type: number
* title: original_shipping_tax_total
* 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:
* - return_requested_total
* - order_change
* - status
* - currency_code
* - id
* - version
@@ -617,6 +618,10 @@
* $ref: "#/components/schemas/AdminCustomer"
* sales_channel:
* $ref: "#/components/schemas/AdminSalesChannel"
* status:
* type: string
* title: status
* description: The order's status.
*
*/
@@ -11,6 +11,7 @@
* - sales_channel_id
* - email
* - currency_code
* - status
* - items
* - shipping_methods
* - payment_status
@@ -232,6 +233,10 @@
* type: number
* title: original_shipping_tax_total
* 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:
* - items
* - shipping_methods
* - status
* - currency_code
* - id
* - region_id
@@ -230,6 +231,10 @@
* description: The order's transactions.
* items:
* $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({
oldParameters: oas.parameters as OpenAPIV3.ParameterObject[],
newParameters: newPathParameters,
type: "path",
types: ["path", "header"],
})
// retrieve updated query and request schemas
@@ -498,7 +498,7 @@ class OasKindGenerator extends FunctionKindGenerator {
oas.parameters = this.updateParameters({
oldParameters: oas.parameters as OpenAPIV3.ParameterObject[],
newParameters: queryParameters,
type: "query",
types: ["query"],
})
if (!oas.parameters.length) {
@@ -1913,7 +1913,7 @@ class OasKindGenerator extends FunctionKindGenerator {
updateParameters({
oldParameters,
newParameters,
type,
types,
}: {
/**
* The old list of parameters.
@@ -1926,13 +1926,13 @@ class OasKindGenerator extends FunctionKindGenerator {
/**
* The type of parameters.
*/
type: ParameterType
types: ParameterType[]
}): OpenAPIV3.ParameterObject[] {
if (!oldParameters) {
return newParameters || []
}
const oppositeParamType = ["path", "query", "header"].filter(
(item) => item !== type
(item) => !types.includes(item as ParameterType)
) as ParameterType[]
const oppositeParams: OpenAPIV3.ParameterObject[] =
oldParameters?.filter((param) =>
@@ -1940,7 +1940,9 @@ class OasKindGenerator extends FunctionKindGenerator {
) || []
// check and update/add parameters if necessary
const existingParams: OpenAPIV3.ParameterObject[] =
oldParameters?.filter((param) => param.in === type) || []
oldParameters?.filter((param) =>
types.includes(param.in as ParameterType)
) || []
const paramsToRemove = new Set<string>()
existingParams.forEach((parameter) => {
@@ -2405,8 +2407,8 @@ class OasKindGenerator extends FunctionKindGenerator {
const fnText = node.getText()
return {
shouldAddFields: fnText.includes(`req.remoteQueryConfig.fields`),
shouldAddPagination: fnText.includes(`req.remoteQueryConfig.pagination`),
shouldAddFields: fnText.includes(`req.queryConfig.fields`),
shouldAddPagination: fnText.includes(`req.queryConfig.pagination`),
}
}