learn-springboot-restapi-sq.../openapi.yml
2023-12-21 19:05:45 +08:00

111 lines
2.7 KiB
YAML

openapi: "3.0.2"
info:
title: Learn Spring Boot RESTful API (SQLite)
version: "1.0"
description: This is an initial draft of API Spec., not generated.
servers:
- url: http://localhost:8888/api/v1
paths:
/users:
get:
summary: Get all users
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
type: object
$ref: "#/components/schemas/User"
post:
summary: Insert a user
requestBody:
description: User object for insertion
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
example: David
password:
type: string
example: 9ff1a0c82d7268b89aeeb112c7f9250b
description: hashed password
# $ref: "#/components/schemas/User"
example:
name: john
password: 9ff1a0c82d7268b89aeeb112c7f9250b
responses:
"201":
description: "The user account has been created"
content:
application/json:
schema:
type: object
$ref: "#/components/schemas/User"
"default":
description: "Unexpected error"
content:
application/json:
schema:
type: array
items:
type: object
$ref: "#/components/schemas/Error"
/users/{id}:
get:
summary: Get a users
parameters:
- in: path
name: id
schema:
type: number
example: 1
required: true
description: User Id for query
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
type: object
$ref: "#/components/schemas/User"
components:
schemas:
User:
properties:
id:
type: integer
example: 123
description: zero-based User ID
name:
type: string
example: David
password:
type: string
example: 9ff1a0c82d7268b89aeeb112c7f9250b
description: hashed password
required:
- id
Error:
properties:
code:
type: string
message:
type: string