Generate Models Using OpenAPI With Lombok Annotations (#14600)
* Generate Models Using OpenAPI With Lombok Annotations * Generate Models Using OpenAPI With Lombok Annotations * Generate Models Using OpenAPI With Lombok Annotations * Generate Models Using OpenAPI With Lombok Annotations
This commit is contained in:
parent
023d73ef61
commit
f091132895
@ -25,10 +25,58 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>${gson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.annotation</groupId>
|
||||||
|
<artifactId>javax.annotation-api</artifactId>
|
||||||
|
<version>${javax.annotation}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger.annotation}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
|
<version>${openapi.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>generate</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<inputSpec>${project.basedir}/src/main/resources/bookapi.yml</inputSpec>
|
||||||
|
<generatorName>java</generatorName>
|
||||||
|
<modelPackage>com.baeldung.openapi.model</modelPackage>
|
||||||
|
<configOptions>
|
||||||
|
<additionalModelTypeAnnotations>@lombok.Data @lombok.NoArgsConstructor @lombok.AllArgsConstructor</additionalModelTypeAnnotations>
|
||||||
|
</configOptions>
|
||||||
|
<generateApis>false</generateApis>
|
||||||
|
<generateSupportingFiles>false</generateSupportingFiles>
|
||||||
|
<generateApiDocumentation>false</generateApiDocumentation>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<properties>
|
||||||
|
<openapi.version>4.2.3</openapi.version>
|
||||||
|
<gson.version>2.10.1</gson.version>
|
||||||
|
<javax.annotation>1.3.2</javax.annotation>
|
||||||
|
<swagger.annotation>1.6.2</swagger.annotation>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.baeldung.lombok.openapiandlombook;
|
||||||
|
|
||||||
|
@lombok.Data
|
||||||
|
@lombok.NoArgsConstructor
|
||||||
|
@lombok.AllArgsConstructor
|
||||||
|
public class Book {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String author;
|
||||||
|
|
||||||
|
}
|
39
lombok-modules/lombok-2/src/main/resources/bookapi.yml
Normal file
39
lombok-modules/lombok-2/src/main/resources/bookapi.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
openapi: 3.0.2
|
||||||
|
info:
|
||||||
|
version: 1.0.0
|
||||||
|
title: Book Store
|
||||||
|
license:
|
||||||
|
name: MIT
|
||||||
|
paths:
|
||||||
|
/books:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- book
|
||||||
|
summary: Get All Books
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Book'
|
||||||
|
|
||||||
|
404:
|
||||||
|
description: Book not found
|
||||||
|
content: { }
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Book:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- author
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
author:
|
||||||
|
type: string
|
Loading…
x
Reference in New Issue
Block a user