openapi-specification-v3.2

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenAPI Specification 3.2

OpenAPI Specification 3.2

Agent-oriented reference for the OpenAPI Specification 3.2.0. Use when editing, generating, or validating OpenAPI descriptions (OAD).
OpenAPI Specification 3.2.0的面向Agent参考文档。适用于编辑、生成或验证OpenAPI描述(OAD)时使用。

When to Use

适用场景

  • Authoring or updating OpenAPI 3.2 YAML/JSON documents
  • Resolving
    $ref
    ,
    $self
    , and relative URIs in multi-document OADs
  • Describing paths, operations, parameters (query/path/header/cookie/querystring), request body, and responses
  • Using Schema Objects (JSON Schema Draft 2020-12 dialect), components, and references
  • Configuring security schemes (apiKey, http, mutualTLS, oauth2, openIdConnect) and requirements
  • Working with media types, encoding (form, multipart), and examples (dataValue/serializedValue/externalValue)
  • 编写或更新OpenAPI 3.2 YAML/JSON文档
  • 解决多文档OAD中的
    $ref
    $self
    和相对URI问题
  • 描述路径、操作、参数(查询/路径/头部/Cookie/查询字符串)、请求体和响应
  • 使用Schema对象(JSON Schema Draft 2020-12方言)、组件和引用
  • 配置安全方案(apiKey、http、mutualTLS、oauth2、openIdConnect)和安全要求
  • 处理媒体类型、编码(表单、多部分)和示例(dataValue/serializedValue/externalValue)

Core References

核心参考

TopicDescriptionReference
OpenAPI ObjectRoot object, openapi, $self, info, servers, paths, webhooks, components, security, tagscore-openapi-object
Format & StructureJSON/YAML, case sensitivity, rich text, OAD structure, parsing, base URIcore-format-and-structure
Fixed & Patterned FieldsFixed vs patterned fields, paths keys, components keys, extensions (x-)core-fixed-patterned-fields
Info & MetadataInfo, Contact, License objectscore-info-metadata
ServerServer Object, Server Variable, URL templatingcore-server
Paths & OperationsPaths Object, Path Item, Operation Object, additionalOperations, querypaths-and-operations
Path TemplatingPath templating, path parameters, matching, ABNFcore-path-templating
ParametersParameter Object, in (path/query/header/cookie/querystring), style, schema vs contentparameters
Request Body & Media TypeRequest Body, Media Type Object, sequential media types, itemSchemarequest-body-and-media-type
Encoding ObjectEncoding by name/position, contentType, style, explode, form, multipartcore-encoding-object
Media TypesContent keys, media type ranges, OpenAPI Media Type Registrycore-media-types
ResponsesResponses Object, Response Object, headers, content, linksresponses
HTTP Status CodesResponse keys, default, 1XX–5XX range with Xcore-http-status-codes
Schema & ComponentsSchema Object (JSON Schema 2020-12), Components, $ref resolutionschema-and-components
Schema JSON Schema KeywordsJSON Schema 2020-12 keywords and OAS extensions in Schemaschema-json-schema-keywords
Schema Composition & PolymorphismallOf, oneOf, anyOf, discriminatorschema-composition-polymorphism
Data Types & FormatsJSON Schema types, format keyword, OAS dialectcore-data-types-and-formats
Discriminator & XMLDiscriminator Object, XML Object (nodeType, name, namespace)core-discriminator-and-xml
Components ReuseReusing parameters, responses, schemas via $refcomponents-reuse
Reference Object$ref, summary/description override, resolution rulescore-reference-object
Header ObjectResponse/multipart headers, style simple, Set-Cookie, Linkcore-header-object
Example ObjectdataValue, serializedValue, value, externalValue, Working with Examplescore-example-object
Tag & External DocsTag Object, External Documentation Object, parent, kindcore-tags-and-external-docs
Link ObjectoperationRef, operationId, parameters, requestBodycore-link-object
Runtime Expressions$request, $response, $url, $method, ABNF, Link/Callback usagecore-runtime-expressions
SecuritySecurity Scheme, OAuth Flows, Security Requirement Objectsecurity
Security Scheme TypesapiKey, http (basic/bearer), mutualTLS, oauth2, openIdConnectsecurity-scheme-types
Security Requirement ObjectOR/AND semantics, {} optional, [] clear, scopessecurity-requirement-object
OAuth2 FlowsOAuth Flows Object, OAuth Flow Object, authorizationCode, deviceAuthorizationsecurity-oauth2-flows
Callbacks & WebhooksCallback Object, webhookscallbacks-and-webhooks
ExtensionsSpecification extensions (x-), extension registriesadvanced-extensions
主题描述参考
OpenAPI对象根对象、openapi、$self、info、servers、paths、webhooks、components、security、tagscore-openapi-object
格式与结构JSON/YAML、大小写敏感性、富文本、OAD结构、解析、基础URIcore-format-and-structure
固定与模式字段固定字段vs模式字段、paths键、components键、扩展(x-)core-fixed-patterned-fields
信息与元数据Info、Contact、License对象core-info-metadata
服务器Server对象、Server变量、URL模板core-server
路径与操作Paths对象、Path Item、Operation对象、additionalOperations、查询paths-and-operations
路径模板路径模板、路径参数、匹配规则、ABNFcore-path-templating
参数Parameter对象、位置(path/query/header/cookie/querystring)、style、schema vs contentparameters
请求体与媒体类型请求体、Media Type对象、顺序媒体类型、itemSchemarequest-body-and-media-type
编码对象按名称/位置编码、contentType、style、explode、表单、多部分core-encoding-object
媒体类型Content键、媒体类型范围、OpenAPI媒体类型注册表core-media-types
响应Responses对象、Response对象、headers、content、linksresponses
HTTP状态码响应键、default、1XX–5XX范围(带X)core-http-status-codes
Schema与组件Schema对象(JSON Schema 2020-12)、Components、$ref解析schema-and-components
Schema JSON Schema关键字Schema中的JSON Schema 2020-12关键字和OAS扩展schema-json-schema-keywords
Schema组合与多态allOf、oneOf、anyOf、discriminatorschema-composition-polymorphism
数据类型与格式JSON Schema类型、format关键字、OAS方言core-data-types-and-formats
鉴别器与XMLDiscriminator对象、XML对象(nodeType、name、namespace)core-discriminator-and-xml
组件复用通过$ref复用参数、响应、schemascomponents-reuse
引用对象$ref、摘要/描述覆盖、解析规则core-reference-object
头部对象响应/多部分头部、simple style、Set-Cookie、Linkcore-header-object
示例对象dataValue、serializedValue、value、externalValue、示例使用core-example-object
标签与外部文档Tag对象、外部文档对象、parent、kindcore-tags-and-external-docs
链接对象operationRef、operationId、parameters、requestBodycore-link-object
运行时表达式$request、$response、$url、$method、ABNF、Link/Callback用法core-runtime-expressions
安全机制Security Scheme、OAuth Flows、Security Requirement对象security
安全方案类型apiKey、http(basic/bearer)、mutualTLS、oauth2、openIdConnectsecurity-scheme-types
安全要求对象OR/AND语义、{}可选、[]清除、scopessecurity-requirement-object
OAuth2流程OAuth Flows对象、OAuth Flow对象、authorizationCode、deviceAuthorizationsecurity-oauth2-flows
回调与WebhooksCallback对象、webhookscallbacks-and-webhooks
扩展规范扩展(x-)、扩展注册表advanced-extensions

Best Practices

最佳实践

TopicDescriptionReference
Spec AuthoringoperationId, tags, $self, components reuse, responses, securitybest-practices-spec-authoring
主题描述参考
规范编写operationId、tags、$self、组件复用、响应、安全机制best-practices-spec-authoring

Advanced

进阶内容

TopicDescriptionReference
Base URI & Resolution$self, retrieval URI, reference resolution, parsing guidanceadvanced-base-uri-and-resolution
Security FilteringEmpty Paths/Path Item, Security Considerationsadvanced-security-filtering
主题描述参考
基础URI与解析$self、检索URI、引用解析、解析指南advanced-base-uri-and-resolution
安全过滤空Paths/Path Item、安全注意事项advanced-security-filtering

Key Points

关键点

  • OAS 3.2 root uses
    openapi: 3.2.0
    ; at least one of
    components
    ,
    paths
    , or
    webhooks
    MUST be present.
  • $self
    provides the document's base URI for reference resolution; use it in multi-document OADs.
  • Schema Object is a superset of JSON Schema Draft 2020-12; empty schema =
    true
    , none =
    false
    .
  • Parameter: use either
    schema
    +
    style
    or
    content
    (one Media Type);
    in: "querystring"
    requires
    content
    .
  • Security at root is OR (one of the Security Requirement Objects); per-operation overrides;
    {}
    = optional.
<!-- Source: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.2.0.md -->
  • OAS 3.2根节点使用
    openapi: 3.2.0
    ;必须至少包含
    components
    paths
    webhooks
    中的一个。
  • $self
    提供文档的基础URI用于引用解析;在多文档OAD中使用。
  • Schema对象是JSON Schema Draft 2020-12的超集;空Schema等价于
    true
    ,无Schema等价于
    false
  • 参数:需使用
    schema
    +
    style
    content
    (单个媒体类型);
    in: "querystring"
    需要使用
    content
  • 根节点的安全机制为OR逻辑(满足任一安全要求对象即可);可通过操作级配置覆盖;
    {}
    表示可选。
<!-- 来源:https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.2.0.md -->