可以定义某种常量参数,我们可以在多个请求中重用它们吗? 例如,如果我有几个端点,并且在所有端点中我需要相同的id(例如书籍ID),是否有机会在文档中定义一次id并在请求定义所需的示例值中引用它?
某些人:bookId := `563`
...........
提前致谢。
答案 0 :(得分:0)
听起来你想使用MSON。 MSON允许您描述对象(如书),并在请求/响应中使用该对象。对象可以相互继承,值可以在其他对象中覆盖,也可以直接在请求/响应属性部分中覆盖。
示例:
## Example Object(object) - Comment about Example Object
+ 'someKey': `someValue` (string, required) - Required String value
有关示例书:
# Data Structures
## Page (object) - A page in a book
+ `pageNumber` (number, required) - The number of the page
## Book (object) - A book
+ `numPages` (number, required) - The number of pages in the book
+ `title` (string, required) - The title of the book
+ `author` (string, required) - The author of the book
+ `pages` (array[object], required) - The pages in the book
## Book Collection (object) - A collection of books
+ books (array[object]) - The books in the collection
# API calls
## Example call [exaple/endpoint]
## Add new book (POST)
+ Request 200 (application/json; charset=utf-8)
+ Attributes (Book)
+ Response 201 (application/json; charset=utf-8)
+ Attributes (Book)
### Get all books (GET)
+ Request 200 (application/json; charset=utf-8)
+ Response 200 (application/json; charset=utf-8)
+ Attributes (Book Collection)