我需要描述一个 api,它在请求正文中包含一个具有必填字段的对象,其中一个字段是一个对象,它本身具有另一组必填字段。
我正在使用 open api v3 和 swagger 编辑器 ( https://editor.swagger.io/ ) 在我将 .yaml 文件放到编辑器上之后,我生成了一个 html 客户端(> 生成客户端 > html)。然后我打开在 .zip 文件中生成的静态页面 index.html 获得此架构:
Table of Contents
body
secureoauthservicesv2Nested_nestedobj
body
id
Integer id of nested obj
nestedobj
secureoauthservicesv2Nested_nestedobj
secureoauthservicesv2Nested_nestedobj
nested object
field1 (optional)
String
field2 (optional)
String
Run Code Online (Sandbox Code Playgroud)
我希望 field1 是必需的,而 field2 是可选的,但事实并非如此。
这是我的 .yaml 文件
openapi: 3.0.0
info:
title: Example API
description: Example API specification
version: 0.0.1
servers:
- url: https://example/api
paths:
/secure/oauth/services/v2/Nested:
post:
summary: Try nested
description: Used to …Run Code Online (Sandbox Code Playgroud)