【发布时间】:2023-03-08 02:42:01
【问题描述】:
如何使用 Swagger (Open API) 2.0 YAML 定义文件在 Swagger UI 3.x 中为正文参数设置 application/json 以外的内容类型?
我的 YAML 文件如下,consumes 元素设置为application/json+fhir 和application/xml+fhir:
swagger: '2.0'
info:
title: Test
version: '1.0'
host: 'server.com'
basePath: /fhir
schemes:
- http
paths:
/Patient/$getrecordsection:
post:
tags:
- Get record section
summary: Retrieve a care record section
consumes:
- application/json+fhir
- application/xml+fhir
produces:
- application/json+fhir
- application/xml+fhir
parameters:
- in: body
name: body
description: ''
required: true
schema:
$ref: '#/definitions/GetRecordSection'
responses:
'200':
description: OK
'400':
description: Bad request
definitions:
GetRecordSection:
type: object
properties:
resourceType:
type: string
default: "Parameters"
parameter:
type: string
example:
resourceType: "Parameters"
parameter:
- name: "patientIdentifier"
valueIdentifier:
system: "http://fhir.provider.net/Id/patient-identifier"
value: "9999999999"
- name: "recordSection"
valueCodeableConcept:
coding:
- system: "http://fhir.provider.net/ValueSet/record-section"
code: "ALL"
xml:
name: Parameters
但是,Swagger UI 仅将application/json 显示为正文参数内容类型:
我正在使用当前最新的 Swagger UI 版本 - 3.11.0。
这是 Swagger UI 的问题,而不是 Swagger 编辑器的问题(尽管我知道两者共享大量组件),因此根本原因可能是相同的。
【问题讨论】:
-
这是最新版本的 Swagger 编辑器中引入的一个错误。请参阅链接的问答。 ^^
-
这是 Swagger UI 而非 Swagger 编辑器的问题,尽管我知道两者共享大量组件,因此根本原因可能是相同的。
标签: swagger swagger-ui swagger-2.0 hl7-fhir