yaml - Open API -> 如何在请求或响应正文 YAML 规范中引用类路径/jar 的 Java 对象的外部属性名称/类型
问题描述
我的要求是使用类路径 java 对象中包含的类的属性名称和类型。
基本上, $ref 将允许我们使用包含在类路径中的类,如下所示
1) **YML File**
paths:
/users/{id}:
parameters:
- name: id
in: path
required: true
description: the user identifier, as userId
schema:
type: string
get:
responses:
'200':
description: the user being returned
content:
application/json:
schema:
$ref: "**TESTCALSSOFCLASSPATHORJAR**"
properties:
uuid: # the unique user id
type: string
format: uuid
2) <plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<configuration>
... excluded for simplicity
<importMappings>
<importMapping>TESTCALSSOFCLASSPATHORJAR=path.to.your.TESTCALSSOFCLASSPATHORJAR</importMapping>
</importMappings>
</configuration>
</plugin>
有什么办法可以从我的类路径/jar java 对象中引用 id 属性名称吗?
paths:
/users/{id}:
parameters:
- name: **id** -> I want to get this prop from TESTCALSSOFCLASSPATHORJAR class
i.e.TESTCALSSOFCLASSPATHORJAR.id
in: path
required: true
description: the user identifier, as userId
schema:
type: string
get:
responses:
'200':
description: the user being returned
content:
application/json:
schema:
$ref: "**TESTCALSSOFCLASSPATHORJAR**"
properties:
uuid: # the unique user id
type: string
format: uuid
参考了下面的文档并进行了很多搜索,但没有找到任何解决方案。
https://github.com/OAI/OpenAPI- 规范 https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin
任何建议将不胜感激。
解决方案
推荐阅读
- c# - 我可以使用 Caliburn Micro - 导体吗
和导体 .Collection.AllActive 在同一个 ShellViewModel - python - 如何停止执行使用 pyinstaller (windows) 创建的 python exe 文件
- reactjs - 输入 React 组件的返回类型
- reactjs - Rollup React 库输出多个构建文件夹?
- r - 将数字添加到数据框中的一系列行 (R)
- sql - SQL - Postgres - TimescaleDB - 用值限制最后两个日期的结果
- c++ - 堆栈分配的类类型。为什么两个 ID 实例的地址相同?
- angular - Angular 8:嵌套服务依赖导致未定义
- r - 使用逗号分隔的字符串从特定数据帧创建频率表
- spring-boot - 如何使用 Spring MVC Test 对多部分 POST 请求进行单元测试?