swagger-ui - OpenAPI 3.0 文件格式在参数中给出了 allowedValues 周围的错误

标签 swagger-ui openapi swagger-editor

我在 OAS 3.0 中指定了 API 规范

post:
  tags:
    - One Time Payment
  summary: One Time Payment API
  operationId: oneTimePaymentUsingPOST
  parameters:
    - in: body
      name: realTimePaymentRequest
      description: realTimePaymentRequest
      required: true
      schema:
        $ref: '#/components/schemas/RealTimePaymentRequest'

当我在 https://editor.swagger.io/ 中编辑此规范文件时- 抛出错误为:
Structural error at paths./banks/payments.post.parameters.0.in
should be equal to one of the allowed values
allowedValues: path, query, header, cookie

我可以看到按照 https://swagger.io/docs/specification/2-0/describing-request-body/ 支持描述 in: body in parameters

认为 Swagger 编辑器抛出错误。这里有什么问题?架构?

任何帮助表示赞赏。谢谢你。

最佳答案

在 OpenAPI 3.0 中,in: bodyin: formData参数被替换为 requestBody :

post:
  tags:
    - One Time Payment
  summary: One Time Payment API
  operationId: oneTimePaymentUsingPOST

  requestBody:
    description: realTimePaymentRequest
    required: true
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/RealTimePaymentRequest'

您发布的文档链接适用于 OpenAPI 2.0。对于 OpenAPI 3.0,请使用此链接:
https://swagger.io/docs/specification/describing-request-body/

关于swagger-ui - OpenAPI 3.0 文件格式在参数中给出了 allowedValues 周围的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60223459/

相关文章:

c# - 来自 Web API 的正确返回类型

windows - 如何解决yaml/swagger中的错误?

hashmap - 具有动态键值 HashMap 的 Swagger 复杂响应模型

java - OpenAPI/Swagger-UI注释和@BeanParam

json - Swagger UI - 无法为请求正文启用 JSON 编辑器

java - 使用 maven 配置 swagger-ui

azure - 为 Service Fabric 中托管的 Swagger UI 启用 Azure AD Auth

swagger-ui - Swagger UI - 添加禁用 "try it out"按钮的 curl 示例

swagger - "bad indentation of mapping entry"错误在 Swagger Editor 中意味着什么?

java - Springdoc 中未禁用 Petstore url(swagger 默认应用程序)