Welcome to the Linux Foundation Forum!

YAML

Hi All, I have created a YAML file named as online grocerystore with 4 HTTP method: GET, POST, PATCH, and DELETE . But I am unable to run it successfully in swagger.The code is pasted below>
Can you please help me to resolve the issues:
openapi: 3.0.0
info:
title: Online Grocery Store
version: 3.0.0
description: >-
This is a online portal to buy day-to-day grocery items. The page is for
demo purpose only.
termsOfService: 'https://www.onlinegrocerystore.in/terms'
contact:
email: info@onlinegrocerystore.in
servers:
- url: '- url: https://www.onlinegrocerystore.dev.in'
- url: '- url: https://www.onlinegrocerystore.uat.in'

paths:
/:/api/v1/groceryitem/itemcode:
get:
summary: Fetches available grocery item details.
description: The API fetches available grocery item details based on fetched item code.
responses:
200:
description: Grocery items are available.
400:
description: Bad Request.

/:/api/v1/groceryitem:
post:
summary: Creates a new grocery item entry.
description: The API creates a new grocery item entry in the database.
parameters:
- $ref: '#/components/parameters/itemcode'
- $ref: '#/components/parameters/itemname'
- $ref: '#/components/parameters/price'
requestBody:
required: true
content:
application/json:
schema:
groceryitem:
- Itemcode: 001
- Itemname: rice
- Price: 40
responses:
201:
description: Grocery items successfully added.
400:
description: Bad Request.

/:/api/v1/groceryitem/itemcode/patch:
patch:
summary: Updates a grocery item entry.
description: The API updates a grocery record in the database.
parameters:
- $ref: '#/components/parameters/itemcode'
- $ref: '#/components/parameters/itemname'
- $ref: '#/components/parameters/price'
requestBody:
required: true
content:
application/json:
schema:
groceryitem:
- Itemcode: 001
- Itemname: rice
- Price: 40
responses:
204:
description: Grocery items successfully updated.
400:
description: Bad Request.

/:/api/v1/groceryitem/itemcode/delete:
delete
summary: Deletes a grocery item.
description: The API deletes a grocery item based on supplied grocery item code.
parameters:
- $ref: '#/components/parameters/itemcode'
- $ref: '#/components/parameters/itemname'
- $ref: '#/components/parameters/price'
requestBody:
required: true
content:
application/json:
schema:
groceryitem:
- Itemcode: 001
- Itemname: rice
- Price: 40
responses:
204:
description: Grocery items successfully deleted.
400:
description: Bad Request.

components:
parameters:

itemcode:
  in: query
  name: itemcode
  description: Grocery item code for a specific item to be stored in the database.
  required: true
  schema:
   type: boolean
   example: true
   enum: [0 100]

itemname:
  in: path
  name: itemname
  description: Grocery item name.
  required: true
  schema:
   type: string

price:
  in: path
  name: price
  description: Price of the grocery item.
  required: true
  schema: 
   type: integer
   example: 40

Comments

Categories

Upcoming Training