gpt4 book ai didi

java - openapi-code-generator 3.3.4 不读取标签并且 API 类名不是预期的

转载 作者:行者123 更新时间:2023-11-30 05:48:54 27 4
gpt4 key购买 nike

我有以下openapi文档。我预计生成的 API 类名将是 SampleApi因为操作“/hello”被标记为“sample” tags 。但它使用 operation 生成 API 类名名字,是HelloApi 。我在这里缺少什么?我正在使用openapi-generator-maven-plugin版本3.3.1


openapi: "3.0.0"
info:
version: 1.0.0
title: Sample Service
tags:
- name: sample
paths:
/hello:
get:
summary: Says hello world
operationId: greet
tags:
- sample
responses:
200:
description: ok
content:
plain/text:<br/>
schema:
type: string
example: Hello World

最佳答案

我找到了解决方案。我们需要在 openapi-generator-maven-pluginconfigOptions 部分使用选项 useTags 设置为 true

默认情况下,useTags 设置为 false,因此它不会使用标记名称来创建 API 类名称。

<configOptions>
<sourceFolder>openapi</sourceFolder>
<interfaceOnly>true</interfaceOnly>
<useBeanValidation>true</useBeanValidation>
<dateLibrary>java8-localdatetime</dateLibrary>
<useTags>true</useTags>
</configOptions>

关于java - openapi-code-generator 3.3.4 不读取标签并且 API 类名不是预期的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54310911/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com