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:

  1. itemcode:
  2. in: query
  3. name: itemcode
  4. description: Grocery item code for a specific item to be stored in the database.
  5. required: true
  6. schema:
  7. type: boolean
  8. example: true
  9. enum: [0 100]
  10.  
  11. itemname:
  12. in: path
  13. name: itemname
  14. description: Grocery item name.
  15. required: true
  16. schema:
  17. type: string
  18.  
  19. price:
  20. in: path
  21. name: price
  22. description: Price of the grocery item.
  23. required: true
  24. schema:
  25. type: integer
  26. example: 40

Comments

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training