UNPKG

fastify-openapi-glue

Version:

generate a fastify configuration from an openapi specification

961 lines (920 loc) 21.7 kB
// implementation of the operations in the openapi specification export class Service { // Operation: addPet // URL: /pet // summary: Add a new pet to the store // req.body // type: object // required: // - name // - photoUrls // properties: // id: // type: integer // format: int64 // category: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Category // name: // type: string // example: doggie // photoUrls: // type: array // xml: // name: photoUrl // wrapped: true // items: // type: string // tags: // type: array // xml: // name: tag // wrapped: true // items: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Tag // status: // type: string // description: pet status in the store // enum: // - available // - pending // - sold // xml: // name: Pet // // valid responses // "405": // description: Invalid input // async addPet(req, _reply) { console.log("addPet", req.params); return { key: "value" }; } // Operation: updatePet // URL: /pet // summary: Update an existing pet // req.body // type: object // required: // - name // - photoUrls // properties: // id: // type: integer // format: int64 // category: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Category // name: // type: string // example: doggie // photoUrls: // type: array // xml: // name: photoUrl // wrapped: true // items: // type: string // tags: // type: array // xml: // name: tag // wrapped: true // items: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Tag // status: // type: string // description: pet status in the store // enum: // - available // - pending // - sold // xml: // name: Pet // // valid responses // "400": // description: Invalid ID supplied // "404": // description: Pet not found // "405": // description: Validation exception // async updatePet(req, _reply) { console.log("updatePet", req.params); return { key: "value" }; } // Operation: findPetsByStatus // URL: /pet/findByStatus // summary: Finds Pets by status // req.query // type: object // properties: // status: // type: array // description: Status values that need to be considered for filter // items: // type: string // enum: // - available // - pending // - sold // default: available // collectionFormat: multi // required: // - status // // valid responses // "200": // description: successful operation // schema: // type: array // items: // type: object // required: // - name // - photoUrls // properties: // id: // type: integer // format: int64 // category: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Category // name: // type: string // example: doggie // photoUrls: // type: array // xml: // name: photoUrl // wrapped: true // items: // type: string // tags: // type: array // xml: // name: tag // wrapped: true // items: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Tag // status: // type: string // description: pet status in the store // enum: // - available // - pending // - sold // xml: // name: Pet // "400": // description: Invalid status value // async findPetsByStatus(req, _reply) { console.log("findPetsByStatus", req.params); return { key: "value" }; } // Operation: findPetsByTags // URL: /pet/findByTags // summary: Finds Pets by tags // req.query // type: object // properties: // tags: // type: array // description: Tags to filter by // items: // type: string // collectionFormat: multi // required: // - tags // // valid responses // "200": // description: successful operation // schema: // type: array // items: // type: object // required: // - name // - photoUrls // properties: // id: // type: integer // format: int64 // category: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Category // name: // type: string // example: doggie // photoUrls: // type: array // xml: // name: photoUrl // wrapped: true // items: // type: string // tags: // type: array // xml: // name: tag // wrapped: true // items: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Tag // status: // type: string // description: pet status in the store // enum: // - available // - pending // - sold // xml: // name: Pet // "400": // description: Invalid tag value // async findPetsByTags(req, _reply) { console.log("findPetsByTags", req.params); return { key: "value" }; } // Operation: getPetById // URL: /pet/:petId // summary: Find pet by ID // req.params // type: object // properties: // petId: // type: integer // description: ID of pet to return // format: int64 // required: // - petId // // valid responses // "200": // description: successful operation // schema: // type: object // required: // - name // - photoUrls // properties: // id: // type: integer // format: int64 // category: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Category // name: // type: string // example: doggie // photoUrls: // type: array // xml: // name: photoUrl // wrapped: true // items: // type: string // tags: // type: array // xml: // name: tag // wrapped: true // items: // type: object // properties: // id: // type: integer // format: int64 // name: // type: string // xml: // name: Tag // status: // type: string // description: pet status in the store // enum: // - available // - pending // - sold // xml: // name: Pet // "400": // description: Invalid ID supplied // "404": // description: Pet not found // async getPetById(req, _reply) { console.log("getPetById", req.params); return { key: "value" }; } // Operation: updatePetWithForm // URL: /pet/:petId // summary: Updates a pet in the store with form data // req.params // type: object // properties: // petId: // type: integer // description: ID of pet that needs to be updated // format: int64 // required: // - petId // // req.body // type: object // properties: // name: // type: string // description: Updated name of the pet // status: // type: string // description: Updated status of the pet // // valid responses // "405": // description: Invalid input // async updatePetWithForm(req, _reply) { console.log("updatePetWithForm", req.params); return { key: "value" }; } // Operation: deletePet // URL: /pet/:petId // summary: Deletes a pet // req.headers // type: object // properties: // api_key: // type: string // // req.params // type: object // properties: // petId: // type: integer // description: Pet id to delete // format: int64 // required: // - petId // // valid responses // "400": // description: Invalid ID supplied // "404": // description: Pet not found // async deletePet(req, _reply) { console.log("deletePet", req.params); return { key: "value" }; } // Operation: uploadFile // URL: /pet/:petId/uploadImage // summary: uploads an image // req.params // type: object // properties: // petId: // type: integer // description: ID of pet to update // format: int64 // required: // - petId // // req.body // type: object // properties: // additionalMetadata: // type: string // description: Additional data to pass to server // file: // type: string // description: file to upload // // valid responses // "200": // description: successful operation // schema: // type: object // properties: // code: // type: integer // format: int32 // type: // type: string // message: // type: string // async uploadFile(req, _reply) { console.log("uploadFile", req.params); return { key: "value" }; } // Operation: getInventory // URL: /store/inventory // summary: Returns pet inventories by status // valid responses // "200": // description: successful operation // schema: // type: object // additionalProperties: // type: integer // format: int32 // async getInventory(req, _reply) { console.log("getInventory", req.params); return { key: "value" }; } // Operation: placeOrder // URL: /store/order // summary: Place an order for a pet // req.body // type: object // properties: // id: // type: integer // format: int64 // petId: // type: integer // format: int64 // quantity: // type: integer // format: int32 // shipDate: // type: string // format: date-time // status: // type: string // description: Order Status // enum: // - placed // - approved // - delivered // complete: // type: boolean // default: false // xml: // name: Order // // valid responses // "200": // description: successful operation // schema: // type: object // properties: // id: // type: integer // format: int64 // petId: // type: integer // format: int64 // quantity: // type: integer // format: int32 // shipDate: // type: string // format: date-time // status: // type: string // description: Order Status // enum: // - placed // - approved // - delivered // complete: // type: boolean // default: false // xml: // name: Order // "400": // description: Invalid Order // async placeOrder(req, _reply) { console.log("placeOrder", req.params); return { key: "value" }; } // Operation: getOrderById // URL: /store/order/:orderId // summary: Find purchase order by ID // req.params // type: object // properties: // orderId: // type: integer // description: ID of pet that needs to be fetched // format: int64 // maximum: 10 // minimum: 1 // required: // - orderId // // valid responses // "200": // description: successful operation // schema: // type: object // properties: // id: // type: integer // format: int64 // petId: // type: integer // format: int64 // quantity: // type: integer // format: int32 // shipDate: // type: string // format: date-time // status: // type: string // description: Order Status // enum: // - placed // - approved // - delivered // complete: // type: boolean // default: false // xml: // name: Order // "400": // description: Invalid ID supplied // "404": // description: Order not found // async getOrderById(req, _reply) { console.log("getOrderById", req.params); return { key: "value" }; } // Operation: deleteOrder // URL: /store/order/:orderId // summary: Delete purchase order by ID // req.params // type: object // properties: // orderId: // type: integer // description: ID of the order that needs to be deleted // format: int64 // minimum: 1 // required: // - orderId // // valid responses // "400": // description: Invalid ID supplied // "404": // description: Order not found // async deleteOrder(req, _reply) { console.log("deleteOrder", req.params); return { key: "value" }; } // Operation: createUser // URL: /user // summary: Create user // req.body // type: object // properties: // id: // type: integer // format: int64 // username: // type: string // firstName: // type: string // lastName: // type: string // email: // type: string // password: // type: string // phone: // type: string // userStatus: // type: integer // format: int32 // description: User Status // xml: // name: User // // valid responses // default: // description: successful operation // async createUser(req, _reply) { console.log("createUser", req.params); return { key: "value" }; } // Operation: createUsersWithArrayInput // URL: /user/createWithArray // summary: Creates list of users with given input array // req.body // type: array // items: // type: object // properties: // id: // type: integer // format: int64 // username: // type: string // firstName: // type: string // lastName: // type: string // email: // type: string // password: // type: string // phone: // type: string // userStatus: // type: integer // format: int32 // description: User Status // xml: // name: User // // valid responses // default: // description: successful operation // async createUsersWithArrayInput(req, _reply) { console.log("createUsersWithArrayInput", req.params); return { key: "value" }; } // Operation: createUsersWithListInput // URL: /user/createWithList // summary: Creates list of users with given input array // req.body // type: array // items: // type: object // properties: // id: // type: integer // format: int64 // username: // type: string // firstName: // type: string // lastName: // type: string // email: // type: string // password: // type: string // phone: // type: string // userStatus: // type: integer // format: int32 // description: User Status // xml: // name: User // // valid responses // default: // description: successful operation // async createUsersWithListInput(req, _reply) { console.log("createUsersWithListInput", req.params); return { key: "value" }; } // Operation: loginUser // URL: /user/login // summary: Logs user into the system // req.query // type: object // properties: // username: // type: string // description: The user name for login // password: // type: string // description: The password for login in clear text // required: // - username // - password // // valid responses // "200": // description: successful operation // schema: // type: string // headers: // X-Rate-Limit: // type: integer // format: int32 // description: calls per hour allowed by the user // X-Expires-After: // type: string // format: date-time // description: date in UTC when token expires // "400": // description: Invalid username/password supplied // async loginUser(req, _reply) { console.log("loginUser", req.params); return { key: "value" }; } // Operation: logoutUser // URL: /user/logout // summary: Logs out current logged in user session // valid responses // default: // description: successful operation // async logoutUser(req, _reply) { console.log("logoutUser", req.params); return { key: "value" }; } // Operation: getUserByName // URL: /user/:username // summary: Get user by user name // req.params // type: object // properties: // username: // type: string // description: "The name that needs to be fetched. Use user1 for testing. " // required: // - username // // valid responses // "200": // description: successful operation // schema: // type: object // properties: // id: // type: integer // format: int64 // username: // type: string // firstName: // type: string // lastName: // type: string // email: // type: string // password: // type: string // phone: // type: string // userStatus: // type: integer // format: int32 // description: User Status // xml: // name: User // "400": // description: Invalid username supplied // "404": // description: User not found // async getUserByName(req, _reply) { console.log("getUserByName", req.params); return { key: "value" }; } // Operation: updateUser // URL: /user/:username // summary: Updated user // req.params // type: object // properties: // username: // type: string // description: name that need to be updated // required: // - username // // req.body // type: object // properties: // id: // type: integer // format: int64 // username: // type: string // firstName: // type: string // lastName: // type: string // email: // type: string // password: // type: string // phone: // type: string // userStatus: // type: integer // format: int32 // description: User Status // xml: // name: User // // valid responses // "400": // description: Invalid user supplied // "404": // description: User not found // async updateUser(req, _reply) { console.log("updateUser", req.params); return { key: "value" }; } // Operation: deleteUser // URL: /user/:username // summary: Delete user // req.params // type: object // properties: // username: // type: string // description: The name that needs to be deleted // required: // - username // // valid responses // "400": // description: Invalid username supplied // "404": // description: User not found // async deleteUser(req, _reply) { console.log("deleteUser", req.params); return { key: "value" }; } }