openapi-specification-v2

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
OpenAPI Specification 2.0 (formerly Swagger 2.0) defines a JSON/YAML format for describing RESTful APIs: paths, operations, parameters, responses, schemas, and security. Use this skill when creating or editing Swagger 2.0 specs, validating structure, or generating code/documentation from them.
The skill is based on OpenAPI Specification 2.0, generated at 2026-01-30.
OpenAPI Specification 2.0(前身为Swagger 2.0)定义了一种JSON/YAML格式,用于描述RESTful API:包括路径、操作、参数、响应、模式和安全等内容。当你创建或编辑Swagger 2.0规范、验证结构,或者从中生成代码/文档时,可以使用本技能。
本技能基于OpenAPI Specification 2.0,生成时间为2026-01-30。

Core References

核心参考

TopicDescriptionReference
Format and StructureDocument format, file structure, data typescore-format-and-structure
Fixed and Patterned FieldsFixed vs patterned field names in the schemacore-fixed-patterned-fields
Swagger ObjectRoot document, required/optional fields, extensionscore-swagger-object
Info and MetadataInfo, Contact, License objectscore-info-metadata
Tags and External DocsTag Object, External Documentation Objectcore-tags-and-external-docs
Reference Object$ref, JSON Pointer, same-document and external file referencescore-reference-object
Data Types and FormatsPrimitives, format table, validation, file typecore-data-types-and-formats
MIME Typesconsumes/produces, RFC 6838, examplescore-mime-types
HTTP Status CodesResponse keys, default response, IANA/RFC 7231core-http-status-codes
Path TemplatingCurly braces, path parameters, name matchingcore-path-templating
Header ObjectResponse header definition (type, format, items, validation)core-header-object
Headers ObjectContainer for response headers (name → Header Object)core-headers-object
Items ObjectNon-body array items (parameters, headers)core-items-object
Example ObjectResponse examples by MIME typecore-example-object
主题描述参考链接
格式与结构文档格式、文件结构、数据类型core-format-and-structure
固定与模式化字段模式中的固定字段与模式化字段名称core-fixed-patterned-fields
Swagger对象根文档、必填/可选字段、扩展core-swagger-object
信息与元数据Info、Contact、License对象core-info-metadata
标签与外部文档Tag对象、外部文档对象core-tags-and-external-docs
引用对象$ref、JSON指针、同文档与外部文件引用core-reference-object
数据类型与格式基本类型、格式表、验证、文件类型core-data-types-and-formats
MIME类型consumes/produces、RFC 6838、示例core-mime-types
HTTP状态码响应键、默认响应、IANA/RFC 7231core-http-status-codes
路径模板大括号、路径参数、名称匹配core-path-templating
头对象响应头定义(类型、格式、项、验证)core-header-object
头集合对象响应头容器(名称 → 头对象)core-headers-object
项对象非主体数组项(参数、头)core-items-object
示例对象按MIME类型分类的响应示例core-example-object

Paths and Operations

路径与操作

TopicDescriptionReference
Paths and OperationsPaths Object, Path Item, Operation Objectpaths-and-operations
Path Item $refExternal path definition, conflict behaviorpath-item-ref
主题描述参考链接
路径与操作Paths对象、Path Item、操作对象paths-and-operations
Path Item $ref外部路径定义、冲突行为path-item-ref

Parameters and Responses

参数与响应

TopicDescriptionReference
ParametersParameter locations (path, query, header, body, formData)parameters
collectionFormatcsv, ssv, tsv, pipes, multi and where they applyparameters-collection-format
Parameters Definitions (Reuse)Root-level parameters, reuse via $refparameters-definitions-reuse
ResponsesResponses Object, Response Objectresponses
Responses Definitions (Reuse)Root-level responses, reuse via $refresponses-definitions-reuse
主题描述参考链接
参数参数位置(路径、查询、头、主体、formData)parameters
collectionFormatcsv、ssv、tsv、pipes、multi及其适用场景parameters-collection-format
参数定义(复用)根级参数、通过$ref复用parameters-definitions-reuse
响应Responses对象、响应对象responses
响应定义(复用)根级响应、通过$ref复用responses-definitions-reuse

Schemas and Definitions

模式与定义

TopicDescriptionReference
Schema and DefinitionsSchema Object, Definitions, composition, polymorphismschema-and-definitions
Schema JSON Schema KeywordsJSON Schema Draft 4 subset and Swagger-specific fieldsschema-json-schema-keywords
主题描述参考链接
模式与定义Schema对象、定义、组合、多态schema-and-definitions
模式JSON Schema关键字JSON Schema Draft 4子集与Swagger特定字段schema-json-schema-keywords

Security

安全

TopicDescriptionReference
SecuritySecurity Definitions, Security Schemesecurity
Security Requirement ObjectApplying security at root/operation, OR/AND logicsecurity-requirement-object
Scopes ObjectOAuth2 scope name → descriptionsecurity-scopes-object
Basic and API Keybasic and apiKey Security Schemesecurity-basic-apikey
OAuth2 Flowsimplicit, password, application, accessCode and required URLssecurity-oauth2-flows
主题描述参考链接
安全安全定义、安全方案security
安全需求对象在根/操作级别应用安全、OR/AND逻辑security-requirement-object
作用域对象OAuth2作用域名称 → 描述security-scopes-object
基础认证与API密钥basic和apiKey安全方案security-basic-apikey
OAuth2流程implicit、password、application、accessCode及所需URLsecurity-oauth2-flows

Best Practices

最佳实践

TopicDescriptionReference
Spec AuthoringoperationId, tags, responses, parameters, definitions, securitybest-practices-spec-authoring
主题描述参考链接
规范编写operationId、标签、响应、参数、定义、安全best-practices-spec-authoring

Advanced

高级内容

TopicDescriptionReference
Vendor Extensionsx- prefix, value types, where allowedadvanced-vendor-extensions
Security FilteringEmpty Paths, empty Path Item for access controladvanced-security-filtering
Extensions and XMLXML Object for schema propertiesadvanced-extensions-and-xml
主题描述参考链接
厂商扩展x-前缀、值类型、允许使用的位置advanced-vendor-extensions
安全过滤空路径、用于访问控制的空Path Itemadvanced-security-filtering
扩展与XML用于模式属性的XML对象advanced-extensions-and-xml