Skip to content

Instantly share code, notes, and snippets.

@sachi-d
Created April 19, 2020 05:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sachi-d/62e364b6489708ed712a004eddccfdb8 to your computer and use it in GitHub Desktop.
Sample yaml file for Payment API
swagger: "2.0"
info:
description: |
API documentation for Sample API.
version: "0.0.1"
title: "Sample API"
host: "payment.swagger.io"
basePath: "/v1"
consumes:
- "application/json"
produces:
- "application/json"
tags:
- name: "payment"
description: "Everything about payments"
schemes:
- "https"
- "http"
paths:
/payment:
get:
tags:
- "payment"
summary: "retrieve payments"
description: "Retrieve all payment records as array"
responses:
200:
description: "successful operation"
schema:
type: "object"
properties:
errorCode:
type: "string"
data:
type: "array"
items:
$ref: "#/definitions/Payment"
default:
$ref: "#/responses/Error"
post:
tags:
- "payment"
summary: "create a new payment"
description: "Create a new payment record and return its ID"
parameters:
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/PaymentToInsert"
responses:
200:
description: "successful operation"
schema:
type: "object"
properties:
data:
type: "string"
description: "application id"
default:
$ref: "#/responses/Error"
put:
tags:
- "payment"
summary: "update an existing payment"
description: "Update a payment record with the details of the request body"
parameters:
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/Payment"
responses:
200:
description: "successful operation"
schema:
type: "object"
properties:
data:
type: "string"
description: "applicaton id"
default:
$ref: "#/responses/Error"
/payment/{id}:
get:
tags:
- "payment"
summary: "retrieve a payment record"
description: "Retrieve details of a payment record defined by the payment ID"
parameters:
- name: "id"
in: "path"
required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
type: "object"
properties:
data:
$ref: "#/definitions/Payment"
default:
$ref: "#/responses/Error"
responses:
Error:
description: "failed operation"
schema:
$ref: "#/definitions/ErrResponse"
definitions:
Payment:
description: "ID must be specified if used as an input request body parameter"
type: "object"
properties:
Id:
type: "string"
Name:
type: "string"
Amount__c:
type: "integer"
PaymentToInsert:
description: "The ID is not specified"
type: "object"
properties:
Name:
type: "string"
Amount__c:
type: "integer"
ErrResponse:
type: "array"
items:
type: "object"
properties:
errorCode:
type: "string"
message:
type: "string"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment