Skip to content

Commit

Permalink
docs-util: fix OAS generation error
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Aug 13, 2024
1 parent fc439a3 commit f58ed91
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/cli/oas/medusa-oas-cli/redocly/redocly-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ decorators:
- AdminProduct
AdminProduct:
- AdminProduct
AdminStockLocation:
- AdminFulfillmentSet
OrderChange:
- Order
StoreShippingOption:
- StoreShippingOption
AdminServiceZone:
- AdminFulfillmentSet
OrderTransaction:
- Order

# Similar config to /www/docs/docusaurus.config.js > redocusaurus
# Allows to emulate rendering of API public documentation when using `yarn redocly preview-docs openapi.yaml`
Expand Down
19 changes: 18 additions & 1 deletion www/utils/generated/oas-output/base/admin.oas.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ servers:
- url: https://api.medusa-commerce.com
paths: {}
components:
schemas:
Error:
title: "Response Error"
type: object
properties:
code:
type: string
description: A slug code to indicate the type of the error.
enum: [invalid_state_error, invalid_request_error, api_error, unknown_error]
message:
type: string
description: Description of the error that occurred.
example: "first_name must be a string"
type:
type: string
description: A slug indicating the type of the error.
enum: [QueryRunnerAlreadyReleasedError, TransactionAlreadyStartedError, TransactionNotStartedError, conflict, unauthorized, payment_authorization_error, duplicate_error, not_allowed, invalid_data, not_found, database_error, unexpected_state, invalid_argument, unknown_error]
responses:
default_error:
description: Default Error
Expand Down Expand Up @@ -246,4 +263,4 @@ components:
type: apiKey
in: cookie
name: connect.sid
x-displayName: Cookie Session ID
x-displayName: Cookie Session ID
17 changes: 17 additions & 0 deletions www/utils/generated/oas-output/base/store.oas.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ servers:
- url: https://api.medusa-commerce.com
paths: {}
components:
schemas:
Error:
title: "Response Error"
type: object
properties:
code:
type: string
description: A slug code to indicate the type of the error.
enum: [invalid_state_error, invalid_request_error, api_error, unknown_error]
message:
type: string
description: Description of the error that occurred.
example: "first_name must be a string"
type:
type: string
description: A slug indicating the type of the error.
enum: [QueryRunnerAlreadyReleasedError, TransactionAlreadyStartedError, TransactionNotStartedError, conflict, unauthorized, payment_authorization_error, duplicate_error, not_allowed, invalid_data, not_found, database_error, unexpected_state, invalid_argument, unknown_error]
responses:
default_error:
description: Default Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ class SchemaFactory {
type: "string",
format: "date-time",
},
$and: {
type: "array",
description:
"Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.",
items: {
type: "object",
},
},
$or: {
type: "array",
description:
"Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.",
items: {
type: "object",
},
},
}

/**
Expand Down
18 changes: 15 additions & 3 deletions www/utils/packages/docs-generator/src/classes/kinds/oas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1653,9 +1653,21 @@ class OasKindGenerator extends FunctionKindGenerator {
(updatedParameter.schema as OpenApiSchema).type !==
(parameter.schema as OpenApiSchema).type
) {
;(parameter.schema as OpenApiSchema).type = (
updatedParameter.schema as OpenApiSchema
).type
// the entire schema should be updated if the type changes.
parameter.schema = updatedParameter.schema
} else if ((updatedParameter.schema as OpenApiSchema).type === "array") {
;(parameter.schema as OpenAPIV3.ArraySchemaObject).items =
this.updateSchema({
oldSchema: (parameter.schema as OpenAPIV3.ArraySchemaObject).items,
newSchema: (updatedParameter.schema as OpenAPIV3.ArraySchemaObject)
.items,
}) || (updatedParameter.schema as OpenAPIV3.ArraySchemaObject).items
} else if ((updatedParameter.schema as OpenApiSchema).type === "object") {
parameter.schema =
this.updateSchema({
oldSchema: parameter.schema,
newSchema: updatedParameter.schema,
}) || updatedParameter.schema
}

if (
Expand Down

0 comments on commit f58ed91

Please sign in to comment.