feat(oas): declare x-codegen on Admin routes - A to D (#3090)

### What

Declare `x-codegen` in OAS for Admin routes - A to D.

### Why

We are introducing a new `x-codegen` OpenApi extension, also known as _vendor extension_, in order to help with passing information down to code generators.

In our case, we wish to declare the `method` name that we would expect to call on a client. This mimics our current JS client package. 
E.g. `medusaClient.product.list` where `product` is the tag of the route and `list` is the x-codegen.method value.

We are also defining the name of a potential typed object for query parameters. OAS 3.0 does not allow to bundle query parameters under a single definition but it is not uncommon to see API clients handle all query parameters as a single typed object, like our JS client package. With x-codegen.queryParams, a code generator can create a named and typed object to bundle all query parameters for a given route. 
E.g. `medusaClient.customer.retrieve(id: string, queryParams: AdminGetCustomerParams)` 

### How

Declare `x-codegen` as an object with fields `method` and `queryParams` on all paths.

Match method and queryParams values with equivalent ones from our current JS client package.

### Test

* Ran OAS validator.
* Ran docs build script.

Expect no visible changes to the documentation.
This commit is contained in:
Patrick
2023-01-23 15:32:20 -05:00
committed by GitHub
parent 6e89d94df8
commit 09dc9c6677
57 changed files with 207 additions and 10 deletions

View File

@@ -37,6 +37,8 @@ import { IsType } from "../../../../utils/validators/is-type"
* application/json:
* schema:
* $ref: "#/components/schemas/AdminPostDraftOrdersReq"
* x-codegen:
* method: create
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -27,6 +27,8 @@ import { validator } from "../../../../utils/validator"
* application/json:
* schema:
* $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsReq"
* x-codegen:
* method: addLineItem
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -9,6 +9,8 @@ import { EntityManager } from "typeorm"
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Draft Order.
* x-codegen:
* method: delete
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -18,6 +18,8 @@ import { MedusaError } from "medusa-core-utils"
* parameters:
* - (path) id=* {string} The ID of the Draft Order.
* - (path) line_id=* {string} The ID of the Draft Order.
* x-codegen:
* method: removeLineItem
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -16,6 +16,8 @@ import { DraftOrder } from "../../../.."
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Draft Order.
* x-codegen:
* method: retrieve
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -21,6 +21,9 @@ import { validator } from "../../../../utils/validator"
* - (query) offset=0 {number} The number of items to skip before the results.
* - (query) limit=50 {number} Limit the number of items returned.
* - (query) q {string} a search term to search emails in carts associated with draft orders and display IDs of draft orders
* x-codegen:
* method: list
* queryParams: AdminGetDraftOrdersParams
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -22,6 +22,8 @@ import { MedusaError } from "medusa-core-utils"
* x-authenticated: true
* parameters:
* - (path) id=* {String} The Draft Order id.
* x-codegen:
* method: markPaid
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -33,6 +33,8 @@ import { IsType } from "../../../../utils/validators/is-type"
* application/json:
* schema:
* $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderReq"
* x-codegen:
* method: update
* x-codeSamples:
* - lang: JavaScript
* label: JS Client

View File

@@ -26,6 +26,8 @@ import { validator } from "../../../../utils/validator"
* application/json:
* schema:
* $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsItemReq"
* x-codegen:
* method: updateLineItem
* x-codeSamples:
* - lang: JavaScript
* label: JS Client