I am writing a API document with the help of Swagger 2.0. I have generated one API where response is in array of books which is working fine.
[{
"id": 1,
"book_name": "The Complete Reference Java8",
"author": "Herbert Schidt",
"genre": "Technology"
}, {
"id": 2,
"book_name": "C Programming",
"author": "Dennis Ritchie",
"genre": "Technology"
}]
Swagger
/fetchBooks:
get:
description: |
Returns an array of book objects.
responses:
200:
description: Successful response
schema:
title: ArrayOfBooks
type: array
items:
type: object
properties:
id:
type: integer
book_name:
type: string
author:
type: string
genre:
type: string
Well, I want to send only one book details in one API in JSONObject
what schema type should I take for it as I tried object is not working.
{
"id": 1,
"book_name": "The Complete Reference Java8",
"author": "Herbert Schidt",
"genre": "Technology"
}
Swagger
/fetchBook:
get:
description: |
Returns a book object
parameters:
- name: id
in: query
description: Books Id's
reqrequired: true
type: integer
format: int
responses:
200:
description: Successful response
schema:
type: object <-- What type should I specify for JSONObject here
items:
type: object
properties:
id:
type: integer
book_name:
type: string
author:
type: string
genre:
type: string
As object is not working, swagger is not showing JSON
format.
Current State :
Expected State :
via Williams
No comments:
Post a Comment