chore(oas): replace requestBody with $ref to req class JSDoc OAS (#2867)
### What Move inline OAS requestBody schema declaration under their respective class-validator classes in order to expose them through `#/components/schemas`. Replace inline OAS requestBody schema with a `$ref` reference pointing to the newly declared schema. ### Why Having requestBody declared as its own "named" schema will allow OAS code generators to output typed entities/DTO that can be manipulate without having to reference the route/operation. ### How Declare a new @schema JSDoc for each class-validator used to parse and validate request body. Move the current inline requestBody to the new @schema. ### Test - Ran OAS validator. - Ran docs build script. Expect no visible changes to the documentation. ### Out-of-scope requestBody of type `multipart/form-data` used for file uploads. These will be address as part of CORE-934 - [create-upload.ts](https://github.com/medusajs/medusa/blob/58d23a7b45b6dde8bdeed0bb268139a0017f1649/packages/medusa/src/api/routes/admin/uploads/create-upload.ts#L87-L90) - [create-protected-upload.ts](https://github.com/medusajs/medusa/blob/58d23a7b45b6dde8bdeed0bb268139a0017f1649/packages/medusa/src/api/routes/admin/uploads/create-protected-upload.ts#L87-L90) Path Parameter and Query Parameter. These will need more research and experimentation, part of CORE-931 --- Resolves CORE-853
This commit is contained in:
@@ -20,19 +20,7 @@ import { validator } from "../../../../utils/validator"
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - email
|
||||
* - password
|
||||
* properties:
|
||||
* email:
|
||||
* type: string
|
||||
* description: The User's email.
|
||||
* format: email
|
||||
* password:
|
||||
* type: string
|
||||
* description: The User's password.
|
||||
* format: password
|
||||
* $ref: "#/components/schemas/AdminPostAuthReq"
|
||||
* x-codeSamples:
|
||||
* - lang: JavaScript
|
||||
* label: JS Client
|
||||
@@ -113,6 +101,22 @@ export default async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminPostAuthReq
|
||||
* type: object
|
||||
* required:
|
||||
* - email
|
||||
* - password
|
||||
* properties:
|
||||
* email:
|
||||
* type: string
|
||||
* description: The User's email.
|
||||
* format: email
|
||||
* password:
|
||||
* type: string
|
||||
* description: The User's password.
|
||||
* format: password
|
||||
*/
|
||||
export class AdminPostAuthReq {
|
||||
@IsEmail()
|
||||
@IsNotEmpty()
|
||||
|
||||
Reference in New Issue
Block a user