Add support for OpenAPI code generation (phase is generate-sources)
This commit is contained in:
59
openapi.yml
Normal file
59
openapi.yml
Normal file
@ -0,0 +1,59 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: swisssign-challenge - dlmw
|
||||
description: |-
|
||||
This is the documentation for the SwissSign Challenge API.
|
||||
termsOfService: ""
|
||||
contact:
|
||||
email: dylan@dlmw.ch
|
||||
license:
|
||||
name: GNU General Public License Version 3
|
||||
url: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
version: 0.0.1
|
||||
externalDocs:
|
||||
description: ""
|
||||
url: ""
|
||||
servers:
|
||||
- url: ""
|
||||
tags:
|
||||
- name: hello
|
||||
description: ""
|
||||
|
||||
paths:
|
||||
/hello:
|
||||
get:
|
||||
tags:
|
||||
- hello
|
||||
summary: Get a hello from me
|
||||
operationId: getHello
|
||||
responses:
|
||||
200:
|
||||
description: "Hello"
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/HelloResponse"
|
||||
|
||||
components:
|
||||
schemas:
|
||||
HelloResponse:
|
||||
type: object
|
||||
properties:
|
||||
value:
|
||||
type: string
|
||||
|
||||
ErrorResponse:
|
||||
type: object
|
||||
required:
|
||||
- message
|
||||
- code
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: Human-readable error message
|
||||
code:
|
||||
type: integer
|
||||
description: Machine-readable error code
|
||||
details:
|
||||
type: object
|
||||
description: Additional error details when available
|
47
pom.xml
47
pom.xml
@ -49,6 +49,31 @@
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.persistence</groupId>
|
||||
<artifactId>jakarta.persistence-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>2.2.28</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>0.2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>2.2.28</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
@ -110,6 +135,28 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>7.11.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>${project.basedir}/openapi.yml</inputSpec>
|
||||
<generatorName>spring</generatorName>
|
||||
<configOptions>
|
||||
<interfaceOnly>true</interfaceOnly>
|
||||
<useSpringBoot3>true</useSpringBoot3>
|
||||
<sourceFolder>src/gen/java/main</sourceFolder>
|
||||
</configOptions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package ch.dlmw.swisssignchallenge.controllers;
|
||||
|
||||
import org.openapitools.api.HelloApi;
|
||||
import org.openapitools.model.HelloResponse;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@Controller
|
||||
public class HelloController implements HelloApi {
|
||||
@Override
|
||||
public ResponseEntity<HelloResponse> getHello() {
|
||||
return ResponseEntity.ok(new HelloResponse().value("Hello, world"));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user