点击 "Generate",模拟 openapi-generator 把同一份 yaml 变成 4 种产物。
openapi: 3.0.3
info: { title: User API, version: 1.0.0 }
paths:
/users:
get:
operationId: listUsers
responses:
'200':
content:
application/json:
schema:
type: array
items: { $ref: '#/components/schemas/User' }
post:
operationId: createUser
requestBody:
content:
application/json:
schema: { $ref: '#/components/schemas/UserCreate' }
responses:
'201':
content:
application/json:
schema: { $ref: '#/components/schemas/User' }
components:
schemas:
User:
type: object
required: [id, name, email]
properties:
id: { type: integer }
name: { type: string }
email: { type: string, format: email }
UserCreate:
type: object
required: [name, email]
properties:
name: { type: string }
email: { type: string, format: email }
💡 真实命令:npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g typescript-axios -o sdk