So I am implementing swagger ui and I want to add response body as content for code 200, which is success. But I am keep on getting this TypeError again and again and I have tried almost many things,but I couldn't solve it. This is the js files which I am adding the swagger. While I am trying to add schemas, it isn't reading and throwing me this error:
.paths\node_modules\swagger-jsdoc\src\specification.js:157
swaggerObject[property][definition],
^
TypeError: Cannot read properties of undefined (reading 'schemas')
The Code is like this:
/**
* @swagger
* components:
* schemas:
* Accounttypes:
* type: string
*/
/**
* @swagger
* paths:
* /api/accounttypes/:
* get:
* summary : Some summary
* tags:
* - Account Types
* description: Some description
* responses:
* '200':
* description: Success Description
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: #/components/schemas/Accounttypes
*/
Can anyone help me with this?
I recently ran into similar problem, a workaround for this is to use 'definitions' instead of 'components'.
Something like this:
/**
* @swagger
* definitions:
* Accounttypes:
* type: string
*/
/**
* @swagger
* paths:
* /api/accounttypes/:
* get:
* summary : Some summary
* tags:
* - Account Types
* description: Some description
* responses:
* '200':
* description: Success Description
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: #/definitions/Accounttypes
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With