To sum it up, I basically am trying to make a swagger Ui based on this "tutorial" : https://github.com/fliptoo/swagger-express
Unfortunately, it doesn't describe at all how to add examples for the body and how to add arrays as well.
The code for the documentation I have right now is :
/** * @swagger * path: /animal/dogs * operations: * - httpMethod: POST * summary: Add several dogs to the animal shelter * notes: Returns results of the post * responseClass: Shelter * nickname : shelterPostWithDogs * consumes: * - application/json * parameters: * - name: body * schema: true * description: Dogs object that needs to be added * paramType: body * required: true * dataType: Dog */
And I have at the bottom :
/** * @swagger * models: * Dog: * id: Dog * properties: * dog_id: * required: true * type: int * Shelter: * id: Shelter * properties: * shelter_id: * type: int * location: * type: string */
Unfortunately, with this, I have this in my Model :
Dog { dog_id (int) }
I would like instead to have this:
Dog { [ { dog_id(int)} ] }
What do I have to change to get this result?
Bonus : How do I add examples to my model? I would like something similar to this one : http://petstore.swagger.io/#!/pet/addPet Unfortunately, I don't know how to do it in swagger express
1 Answers
Answers 1
I am also very new to swagger-express but one thing I will suggest, you have to use type as "array" in models definition:
Dog: id: Dog properties: dog_id: required: true type: **array**
Hope this will help you.
Thanks!
0 comments:
Post a Comment