API通用信息
将有关API的通用信息(例如版本号、许可说明、联系方式、文档链接等)包含在规范中被认为是一种良好实践。我们特别建议对公开可用的API这样做;因为这可以增加用户对贵公司提供的服务的信心。要指定API元数据,您可以使用顶层info
对象的属性
1openapi: 3.0.42info:3 # You application title. Required.4 title: Sample Pet Store App5
6 # API version. You can use semantic versioning like 1.0.0,7 # or an arbitrary string like 0.99-beta. Required.8 version: 1.0.09
10 # API description. Arbitrary text in CommonMark or HTML.11 description: This is a sample server for a pet store.12
13 # Link to the page that describes the terms of service.14 # Must be in the URL format.15 termsOfService: http://example.com/terms/16
17 # Contact information: name, email, URL.18 contact:19 name: API Support20 email: support@example.com21 url: http://example.com/support22
23 # Name of the license and a URL to the license description.24 license:25 name: Apache 2.026 url: https://apache.ac.cn/licenses/LICENSE-2.0.html27
28# Link to the external documentation (if any).29# Code or documentation generation tools can use description as the text of the link.30externalDocs:31 description: Find out more32 url: http://example.com
title
和version
属性是必需的,其他是可选的。