Ank*_*dit 5 enums yaml openapi
Swagger: Reusing an enumDefinition as queryparameter中提出了类似的问题。我的问题是我是否可以使用枚举(可重复使用或不可重复使用)。每当我尝试这样做时,我都会收到错误,但是使用字符串不会给出任何错误
\n/path/{protocol}:\n patch:\n summary:\n operationId:\n tags:\n parameters:\n - name: protocol\n in: path\n description: # some description\n required: true\n schema:\n $ref: "#/components/schemas/ProtocolType"\n\n ProtocolType:\n type: string\n default: abcd\n enum:\n - abcd\n - aaa\n - bbb\nRun Code Online (Sandbox Code Playgroud)\n我的问题是上面的例子是否有效或者我应该尝试哪些可能的改变。我正在使用 OpenAPI 3.0.0 。
\n错误:
\nCompilation errors in XX.client.cpp\nXX.client.cpp: In static member function \xe2\x80\x98static void \nXX::SendSetProtocolReqRequest(std::string, const \nXX::model::SetProtocolReq_Request*, \nHTTPRequestEventContext::Ptr, uint64_t, HTTPClient*, FSM*, Statistics*, \nstd::string, bool)\xe2\x80\x99:\nXX_Management.client.cpp:1822:33: error: no matching function for call to \n\xe2\x80\x98Json::ToValue(XX::model::XXEnumProtocolType*, \nframework::json::Value*)\xe2\x80\x99\n Json::ToValue(¶m, &value); \n ^\nRun Code Online (Sandbox Code Playgroud)\n我对 XX.client.cpp 不太了解。它是编译 yaml 文件后自动生成的文件。
\n小智 5
对于 SwaggerUI - 使用 2.0 规范,您必须使用内联枚举,例如:
swagger: '2.0'
info:
title: Report API
version: v1
paths:
/report/{reportType}:
get:
tags:
- ReportController
parameters:
- in: path
name: reportType
required: true
type: string
enum: [foo, bar, baz]
Run Code Online (Sandbox Code Playgroud)
在3.0中,您可以使用参考:
---
openapi: 3.0.1
info:
title: Report API
version: v1
paths:
"/report/{reportType}":
get:
tags:
- ReportController
parameters:
- name: exportType
in: path
description: ''
required: true
schema:
"$ref": "#/components/schemas/ReportType"
components:
schemas:
ReportType:
enum:
- foo
- bar
- baz
type: string
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9659 次 |
| 最近记录: |