OpenAPI 3.1 合约驱动开发与客户端生成指南规范片段openapi: 3.1.0

info:

title: Sample API

version: 1.0.0

paths:

/items/{id}:

get:

parameters:

- name: id

in: path

required: true

schema: { type: string }

responses:

'200':

description: OK

content:

application/json:

schema:

$ref: '#/components/schemas/Item'

components:

schemas:

Item:

type: object

properties:

id: { type: string }

name: { type: string }

生成示例openapi-generator-cli generate -i openapi.yaml -g typescript-fetch -o client

要点保持响应类型与错误模型一致使用语义化版本管理合约演进总结在合约驱动模式下,OpenAPI 结合生成工具可提升跨端协作效率与一致性。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部