Swagger
#Swagger
https://swagger.io/
右上「Sign In」、Githubアカウントで。
Create API
https://gyazo.com/888d65553622ab4c1bbd88374d29693b
https://app.swaggerhub.com/apis/fuurin/svelte-bulletin-board/1.0.0#/
なんか色々頑張ってSwagger Specなるものを書く。Swaggerの記法まとめ - Qiita
最初2.0だったけどSaveの右にあるメニューから3.0にConvertできた OpenAPI (Swagger) 超入門 - Qiita
できたコード
code: swagger.yaml
openapi: 3.0.0
info:
description: A sample API for Svelte Bulletin Board
version: 1.0.0-oas3
title: Svelte Bulletin Board API
paths:
/:
get:
summary: Obtain all the comments
operationId: all
parameters:
- in: query
name: time
description: Specifies a point on the time line
required: false
schema:
type: integer
format: int32
responses:
'200':
description: Success to obtain the comments
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Comment'
'400':
description: bad input parameter
post:
summary: Submit a comment
operationId: comment
description: Submit a comment
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Comment'
description: The object of comment to submit
responses:
'201':
description: item created
'400':
description: 'invalid input, object invalid'
delete:
summary: Delete all the comments
operationId: reset
description: Delete all the comments
responses:
'200':
description: all comments are deleted
'400':
description: error
servers:
- url: 'https://virtserver.swaggerhub.com/fuurin/svelte-bulletin-board/1.0.0'
components:
schemas:
Comment:
type: object
required:
- name
- text
properties:
id:
type: integer
format: int32
example: 1
name:
type: string
example: Anonymous
text:
type: string
example: Hello Svelte!
timestamp:
type: string
format: date-time
example: '2021-04-01 07:00:00'
できたら右上のExportからStubコードをダウンロードできる。