swagger-codegen 相关问题

Swagger Code Generator允许通过(Swagger)OpenAPI规范生成API客户端库,服务器存根和文档。

如何解决 OpenAPI Generator Maven 插件中的“reference to Type is ambigeous error”?

我的 openapi-generator-maven 插件配置如下 org.openapitools openapi-generator-maven-plugin 我的 openapi-generator-maven 插件配置如下 <plugin> <groupId>org.openapitools</groupId> <artifactId>openapi-generator-maven-plugin</artifactId> <version>7.1.0</version> <configuration> <generateSupportingFiles>true</generateSupportingFiles> <generatorName>spring</generatorName> <generateApiDocumentation>true</generateApiDocumentation> <generateModelDocumentation>true</generateModelDocumentation> <globalProperties> <skipFormModel>false</skipFormModel> </globalProperties> <!-- Duplicate classes being generated due to https://github.com/OpenAPITools/openapi-generator/issues/2701 --> <typeMappings> string+binary=StreamingResponseBody,ExpensePartnerConfig1=ExpensePartnerConfig,FeatureConfig1=FeatureConfig,Application1=Application,PaymentSourceInfo1=PaymentSourceInfo,CostCenter1=CostCenter,OAuthPartnerConfig1=OAuthPartnerConfig,DateTimeRange1=DateTimeRange,TmcInfo1=TmcInfo,Company1=Company,SupportConfig1=SupportConfig,RewardsProgram1=RewardsProgram,CompanyBasicInfo1=CompanyBasicInfo,UserPersonalInfo1=UserPersonalInfo,PnrData1=PnrData,Agent1=Agent,DocumentMetadata1=DocumentMetadata,Document1=Document,BasicTripInfo1=BasicTripInfo,VendorProgramPaymentDescriptor1=VendorProgramPaymentDescriptor,VendorProgramPaymentDescriptorWrapper1=VendorProgramPaymentDescriptorWrapper,WhiteLabelConfig1=WhiteLabelConfig,AirBookTravelerInfo1=AirBookTravelerInfo,UserGroup1=UserGroup,Question1=Question,PaymentSourceMetadata1=PaymentSourceMetadata,EventLocation1=EventLocation,EventUserRsvp1=EventUserRsvp,FormOfPayment1=FormOfPayment,PaymentSourceFilter1=PaymentSourceFilter,PaymentSourceTravelType1=PaymentSourceTravelType,PaymentSourceMappings1=PaymentSourceMappings,PaymentSourceMapping1=PaymentSourceMapping,PaymentSourceSpendType1=PaymentSourceSpendType,PaymentSourceAttributes1=PaymentSourceAttributes,LegalEntityFilter1=LegalEntityFilter,CompanyFilter1=CompanyFilter,CountryFilter1=CountryFilter,CostCenterFilter1=CostCenterFilter,PaymentSourceDepartmentFilter1=PaymentSourceDepartmentFilter,TravelerEventSummary1=TravelerEventSummary,AccessTypeAttributes1=AccessTypeAttributes,TravelTypeFilter1=TravelTypeFilter,PrivacyNotice1=PrivacyNotice </typeMappings> <importMappings> StreamingResponseBody=org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody </importMappings> <configOptions> <oas3>true</oas3> <useTags>true</useTags> <withSeparateModelsAndApi>true</withSeparateModelsAndApi> <delegatePattern>true</delegatePattern> <withInterfaces>true</withInterfaces> <library>spring-boot</library> <dateLibrary>java8</dateLibrary> <useSpringfox>false</useSpringfox> <useSpringController>true</useSpringController> <openApiNullable>false</openApiNullable> <modelPropertyNaming>camelCase</modelPropertyNaming> <useJakartaEe>true</useJakartaEe> </configOptions> <additionalProperties>removeEnumValuePrefix=false</additionalProperties> </configuration> <executions> <execution> <id>generate-client</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> <configuration> <inputSpec>${project.basedir}/target/classes/generated/yaml/apis/api/Api.yaml </inputSpec> <generatorName>java</generatorName> <generateApiDocumentation>false</generateApiDocumentation> <modelNamePrefix>Spotnana</modelNamePrefix> <generateModels>true</generateModels> <generateApis>true</generateApis> <library>okhttp-gson</library> <configOptions> <library>okhttp-gson</library> </configOptions> <additionalProperties>removeEnumValuePrefix=true</additionalProperties> <output>${project.build.directory}/generated-sources/openapi/client</output> </configuration> </execution> </executions> </plugin> 我在生成过程中收到以下错误。有人可以建议我如何解决这个问题吗? [ERROR] /Users/debrajmanna/code/java/github/spotnana/src/java/openapi-generator/target/generated-sources/openapi/client/src/main/java/org/openapitools/client/model/ServiceChargeRecord.java:[76,10] error: reference to Type is ambiguous both enum org.openapitools.client.model.Type in org.openapitools.client.model and interface java.lang.reflect.Type in java.lang.reflect match [ERROR] /Users/debrajmanna/code/java/github/spotnana/src/java/openapi-generator/target/generated-sources/openapi/client/src/main/java/org/openapitools/client/model/ServiceChargeRecord.java:[164,41] error: reference to Type is ambiguous 如错误消息中所述,您应该决定在 ServiceChargeRecord.java 类中导入哪一个。 要么: import org.openapitools.client.model.Type; 或者: import java.lang.reflect.Type;

回答 1 投票 0

有没有办法让nswag的行为与swaggerhub的swagger导出相同?

这个答案演示了 swaggerhub 的行为 - 输入 yaml 文件中的每个 operationId 都会在生成的 cs 文件中产生两个方法,一个具有 WithHttpInfo 后缀,另一个没有...

回答 1 投票 0

如何在 Spring Boot 应用程序中定义 Swagger SecurityScheme

我正在尝试将 http 基本身份验证要求定义为我的应用程序的默认要求: 成分: 安全方案: 基本验证: 类型:http 方案:基本 但我的 BasicAuth 安全类不是

回答 3 投票 0

Swagger 版本更改破坏了我的 Typescript 模型文件

在我目前正在进行的一个项目中,曾经有一个swagger.json文件版本2。现在他们更改为swagger 3.0.2 这是上一篇。从 swagger.json 生成类型的命令 招摇-

回答 1 投票 0

Swagger Codegen CLI Java 客户端每个实例一个访问令牌,不是线程安全的

我有openapi 3.0规范。 生成代码: java -jar /usr/bin/swagger-codegen-cli-v3.jar 生成 -l java -i openapi_shop.yaml -o apishop -DhideGenerationTimestamp=true -c config_shop.jso...

回答 1 投票 0

在生成 swagger 客户端时禁用模型名称中的前缀

我对Golang很陌生,尝试在golang中生成客户端代码 我的 swagger 文件的模型名称为 models.BaseModel,但客户端代码包含名称为 models.ModelsBaseModel 我想避免这种情况

回答 1 投票 0

如何强制 Swagger Codegen 生成未从任何其他对象引用的枚举?

我有一个包含多个枚举的 OpenAPI 规范: 社交链接类型: 类型:字符串 枚举: - FACEBOOK - YOUTUBE - Instagram - 推特 - Pinterest - 领英 - 抖音 - 翻滚...

回答 2 投票 0

Swagger 2.0 类型字符串格式:日期时间在 Spring Boot 中不输出 yyyy-MM-dd'T'HH:mm:ssZ

我有一个 Spring Boot 2.7 项目,它使用 swagger-codegen-maven-plugin 版本 2.4.1 为我生成模型。 我需要日期格式遵循 ISO-8601 格式,即 yyyy-MM-dd'T'HH:...

回答 2 投票 0

OpenAPI生成器:通过标签选择或跳过API

我有一个很大的 OpenAPI 文件,其中有很多用 API 列表标记的方法,例如: 标签: - 名称:市场 API 描述:用于使用 Marketplace Payment Flow 的 API - 姓名:

回答 2 投票 0

有没有办法使用 swagger-codegen 使用 Jakarta 而不是 Javax 生成源代码

我需要使用 swagger codegen gradle 插件和 Jakarta 包生成 spring 控制器源代码,但我在配置中看不到这样做的选项 我尝试使用以下选项来基因...

回答 3 投票 0

FastAPI 是否正确生成此 Enum?如果是,为什么 openapi-generator 认为它无效?

我不太确定问题出在哪里,但是FastAPI生成了一个Swagger文件,我相信这是真的,并且最新版本中的openapi-generator-cli认为Swagger文件无效。该...

回答 1 投票 0

使用 AML SDK V2 自动为 Azure ML 端点生成 Swagger

参考示例:https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-advanced-entry-script?view=azureml-api-1#automatically-generate -a-swagger-模式 我正在寻求增强...

回答 1 投票 0

无法在项目 swagger-java-client 上执行目标:编译失败

上下文:我正在尝试构建一个 swagger-codegen-cli 生成的包来生成一个 jar 作为 Maven Spring Boot Java 项目的依赖项 运行 mvn clean install 时收到此错误消息: [

回答 1 投票 0

如何禁用 swagger-codegen java.io.InputStream 转换

我得到了返回的休息: java.io.InputStream, com.fasterxml.jackson.databind.JsonNode, org.springframework.core.io.InputStreamRecource 但在结果 swagger-codegen 生成的 API 中,我得到了休息,那就

回答 1 投票 0

如何在开放 API 规范中为字符串类型的属性指定空字符串值作为默认值

我有一个打开的 api yaml 文件,如下所示。我想将空字符串值指定为字符串类型属性的默认值。有什么方法可以做到这一点 测试: 类型:对象 必需的: ['', ''] 特性: 测试...

回答 2 投票 0

如何使用python读取openapi json schema并提取API信息

我在本地 PC 中保存了一个 openapi json 架构文件。使用 python 脚本我想读取该 json 文件并提取其中定义的所有 API(包括 API 定义、请求标头、请求...

回答 1 投票 0

如何在OpenApi中定义别名,最终在Pojo中使用它

假设我的 openapi.yml 中有这个定义(这只是一个虚构的示例来描述我遇到的问题): 成分: 模式: 地址: 类型:对象 特性: 呐...

回答 2 投票 0

JSON 中位置 0 的意外标记 n swagger-axios-codegen

我无法使用swagger axios codegen的deleteOne功能,即使我在BE下面尝试过并且邮递员仍在运行 我尝试从旧版本安装到最新版本,但无法使用

回答 1 投票 0

我想从给定的 swagger.json 创建curl 请求?

我正在寻找一种解决方案,从java中的curl、GO、Node.js中的swagger.json中提取api请求!

回答 1 投票 0

AddSwaggerGen - 在 swagger.json 中为未使用的 DTO 创建对象

我使用 services.AddSwaggerGen() 创建 swagger.json: 服务.AddSwaggerGen(c => { c.CustomOperationIds(apiDesc => { if (apiDesc.TryGetMethodInfo(out var methodInfo)) { ...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.