swagger-codegen

OpenApi Generator reference an external POJO in YAML file specification

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-17 02:00:03
问题 I'm using OpenApi v3.3.4 (formerly called Swagger CodeGen ) maven plugin to generate my rest controller via api.yml files where I describe all the operations I want to expose. In my use case, I want to expose a method POST: handleNotification(@RequestBody SignatureNotification notification) wich its request body's type is generated via another maven-plugin in /targer folder. Actually I'm defining SignatureNotification in Components part of my .yml file : ... requestBody: required: true

How to add Jackson annotations to specific fields on swagger generated model classes for Spring

余生颓废 提交于 2021-02-11 00:04:11
问题 Folks, With swagger 2.0 does anyone know if it's possible to add Jackson annotations to specific fields on swagger generated model classes when using swagger codegen with 'spring' as the 'language' <language>spring</language> ? I want to use Jackson JSON Views & would like to add the view annotations to provide different views of the generated models when I return them from the various REST endpoints. However, I could not find any documentation if any on this on swagger. I see this slightly

How to add Jackson annotations to specific fields on swagger generated model classes for Spring

耗尽温柔 提交于 2021-02-10 23:58:11
问题 Folks, With swagger 2.0 does anyone know if it's possible to add Jackson annotations to specific fields on swagger generated model classes when using swagger codegen with 'spring' as the 'language' <language>spring</language> ? I want to use Jackson JSON Views & would like to add the view annotations to provide different views of the generated models when I return them from the various REST endpoints. However, I could not find any documentation if any on this on swagger. I see this slightly

How to Create a Spring-Boot REST Server Using OpenAPITools

社会主义新天地 提交于 2021-01-28 07:53:34
问题 I created a Spring Boot server using the tools at swagger.io, which I'm now porting to OpenAPITools. But I can't find the equivalent generator. I tried setting the generaterName to spring, but it creates a somewhat different application. First, it uses a WebMvcConfigurer Bean, even though it's not an MVC application. Second, the generated Controller and API don't give me an ObjectMapper. Third, instead of an HttpServletRequest, they give me a more ambiguous NativeWebRequest instance. Is there

Swagger codegen generate too long string literals

不打扰是莪最后的温柔 提交于 2021-01-28 05:21:43
问题 I need to generate classes based on provided swagger file. Unfortunately I have no influence on content of this file. My config in gladle looks like: task generateApi { doLast { def config = new CodegenConfigurator() config.setInputSpec("file:///$projectDir/$swaggerSourceFile") config.setOutputDir("$projectDir/$swaggerTargetFolder") config.setLang('spring') config.setAdditionalProperties([ 'interfaceOnly' : true, 'apiPackage' : 'somepackage', 'modelPackage' : 'somepackage.domain',

Why discriminator property gets serialized twice?

心已入冬 提交于 2021-01-23 06:14:11
问题 I'm using OpenAPI 3.0 inheritance in components schemas and I have the (Java) classes generated by openapi-generator (which uses Jackson). Why the discriminator property gets serialized twice in the resulting JSON? This is a JHipster API-First project, which should use openapi-generator for generating the Java model (POJOs with Jackson annotations) and API controllers (interfaces with Spring's @Api annotations). By following the OpenAPI 3.x documentation/examples, it seems that the property

基于Swagger+SpringBoot快速构建javaweb项目

你说的曾经没有我的故事 提交于 2021-01-20 07:34:48
章节导航 SpringBoot&Swagger简介 数据模型和接口定义 项目框架生成 业务逻辑实现 项目源码地址   github项目路径: https://github.com/Vikezhu/springboot-template 一、SpringBoot&Swagger简介    SpringBoot   SpringBoot实质上也是基于Spring的一种开发框架,但相比使用Spring框架那些复杂配置过程,以及集成其他框架时带来的诸多兼容性问题,SpringBoot可以更高效的搭建Spring框架,简化项目框架的配置,提升应用开发的效率,是开发人员更专注于应用的开发。而且SpringBoot还可以非常方便地集成各种主流框架(如SpringCloud、MyBatis等)。   目前,使用idea等IDE工具自带插件,或者通过 https://start.spring.io/ 网站,均可快速的构建一个空白的SpringBoot项目。    Swagger   Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。它可以通过在线编辑接口文档和数据模型定义,快速生成SpringBoot项目,并构建出用户定义的对外服务restful接口,以及相关的数据实体类。另外,swagger生成的项目还内嵌由swagger-ui页面

Swagger Codegen use existing class

断了今生、忘了曾经 提交于 2020-12-01 10:52:27
问题 How can I get the swagger codegen to use an existing class instead of creating a new class? Is this possible? For instance I want to use org.springframework.data.domain.Page instead of swagger creating another page class. 回答1: You could use --import-mappings , as it is explained here: Sometimes you don't want a model generated. In this case, you can simply specify an import mapping to tell the codegen what not to create. When doing this, every location that references a specific model will

Swagger Codegen use existing class

纵然是瞬间 提交于 2020-12-01 10:52:04
问题 How can I get the swagger codegen to use an existing class instead of creating a new class? Is this possible? For instance I want to use org.springframework.data.domain.Page instead of swagger creating another page class. 回答1: You could use --import-mappings , as it is explained here: Sometimes you don't want a model generated. In this case, you can simply specify an import mapping to tell the codegen what not to create. When doing this, every location that references a specific model will