I am using Swagger Hub to generate API and wanting to get multiple responses for the get request: https://virtserver.swaggerhub.com/factly/test/1.0.0/categories
Following is how I defined my API. When I execute the API I only get one category in response. How do I get all the three categories defined as a response? Any help is greatly appreciated.
openapi: 3.0.0
info:
description: This is the sample API for Core
version: "1.0.0"
title: Dega Core API
tags:
- name: Core
description: Operations related to Core
paths:
/categories:
get:
tags:
- Core
summary: gets all the categories
description: this is to get all the available categories
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CategoryItem'
examples:
category1:
$ref: '#/components/examples/category1'
category2:
$ref: '#/components/examples/category2'
category3:
$ref: '#/components/examples/category3'
components:
schemas:
CategoryItem:
type: object
required:
- id
- name
- slug
- createdDate
properties:
id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
name:
type: string
example: Category 1
slug:
type: string
example: category-1
description:
type: string
example: This is a sample category
parent:
type: string
example: null
createdDate:
type: string
format: date-time
example: '2016-08-29T09:12:33.001Z'
examples:
category1:
value:
id: d290f1ee-6c54-4b01-90e6-d701748f0851
name: Category 1
slug: category-1
description: This is the sample description for Category 1
parent: null
createdDate: '2016-08-29T09:12:33.001Z'
category2:
value:
id: d290f1ee-6c54-4b01-90e6-d701748f0851
name: Category 2
slug: category-2
description: This is the sample description for Category 2
parent: null
createdDate: '2016-08-29T09:12:33.001Z'
category3:
value:
id: d290f1ee-6c54-4b01-90e6-d701748f0851
name: Category 3
slug: category-3
description: This is the sample description for Category 3
parent: d290f1ee-6c54-4b01-90e6-d701748f0851
createdDate: '2016-08-29T09:12:33.001Z'
servers:
- url: 'https://virtserver.swaggerhub.com/factly/test/1.0.0'
The response I am expecting is the following:
[{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": "Category 1",
"slug": "category-1",
"description": "This is the sample description for Category 1",
"createdDate": "2016-08-29T09:12:33.001Z"
},
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": "Category 2",
"slug": "category-2",
"description": "This is the sample description for Category 2",
"createdDate": "2016-08-29T09:12:33.001Z"
},
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": "Category 3",
"slug": "category-3",
"description": "This is the sample description for Category 3",
"parent": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"createdDate": "2016-08-29T09:12:33.001Z"
}]
Thanks, Shashi