Fix package reference bug

This commit is contained in:
2025-10-12 13:54:51 +02:00
parent 97aaa715dc
commit 671c1214a8
121 changed files with 6431 additions and 69 deletions

View File

@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@@ -0,0 +1,6 @@
.openapi-generator-ignore
README.md
pom.xml
src/main/java/api/ApiUtil.java
src/main/java/api/ExampleApi.java
src/main/java/model/ExampleSchema.java

View File

@@ -0,0 +1,27 @@
# OpenAPI generated API stub
Spring Framework stub
## Overview
This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub.
This is an example of building API stub interfaces in Java using the Spring framework.
The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints
by adding ```@Controller``` classes that implement the interface. Eg:
```java
@Controller
public class PetController implements PetApi {
// implement all PetApi methods
}
```
You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg:
```java
@FeignClient(name="pet", url="http://petstore.swagger.io/v2")
public interface PetClient extends PetApi {
}
```

View File

@@ -0,0 +1,25 @@
inputSpec: /api/generated/example/java/example/openapi/openapi/openapi.yaml
generatorName: spring
templateDir: /api/templates/7.3.0/spring/
outputDir: /api/generated/example/java/example
additionalProperties:
groupId : "com.example"
artifactId : "example-api"
apiPackage : "api"
modelPackage : "model"
artifactVersion : "1.0.0"
library : "spring-boot"
java8 : "true"
dateLibrary : "java8"
serializableModel : "true"
serializationLibrary : "jackson"
interfaceOnly : "true"
skipDefaultInterface : "true"
prependFormOrBodyParameters : "true"
useTags : "true"
bigDecimalAsString : "true"
booleanGetterPrefix : "is"
useBeanValidation : "false"
hideGenerationTimestamp : "true"
openApiNullable : "false"

View File

@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@@ -0,0 +1,3 @@
.openapi-generator-ignore
README.md
openapi/openapi.yaml

View File

@@ -0,0 +1,2 @@
# OpenAPI YAML
This is a OpenAPI YAML built by the [openapi-generator](https://github.com/openapitools/openapi-generator) project.

View File

@@ -0,0 +1,67 @@
openapi: 3.0.3
info:
description: Some demonstration stuff
title: Example API
version: 1.0.0
servers:
- url: /
paths:
/example/{exampleId}/:
get:
operationId: GetExampleById
parameters:
- description: the id of an example
in: path
name: exampleId
required: true
schema:
$ref: '#/components/schemas/ExampleSchema'
responses:
"200":
content:
application/json:
schema:
items:
$ref: '#/components/schemas/ExampleSchema'
type: array
description: The example associated with this id
"400":
description: "The server cannot or will not process the request due to something\
\ that is perceived to be a client error (e.g., malformed request syntax,\
\ invalid request message framing, or deceptive request routing)."
"403":
description: "Forbidden: the server is refusing action, you do not have\
\ the necessary permissions this resource"
"500":
description: The server encountered an unexpected condition which prevented
it from fulfilling the request
summary: Get example associated with this id
tags:
- Example
components:
parameters:
exampleId:
description: the id of an example
in: path
name: exampleId
required: true
schema:
$ref: '#/components/schemas/ExampleSchema'
schemas:
ExampleSchema:
example:
name: name
description: description
id: b1e0773f-ef0c-43cf-a1df-52d17f4a3017
properties:
id:
example: b1e0773f-ef0c-43cf-a1df-52d17f4a3017
format: uuid
type: string
name:
nullable: false
type: string
description:
nullable: true
type: string
type: object

View File

@@ -0,0 +1,64 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example-api</artifactId>
<packaging>jar</packaging>
<name>example-api</name>
<version>1.0.0</version>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springdoc.version>1.6.14</springdoc.version>
<swagger-ui.version>5.3.1</swagger-ui.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.15</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<!--SpringDoc dependencies -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,19 @@
package api;
import org.springframework.web.context.request.NativeWebRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ApiUtil {
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
try {
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
res.setCharacterEncoding("UTF-8");
res.addHeader("Content-Type", contentType);
res.getWriter().print(example);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,68 @@
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package api;
import model.ExampleSchema;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Tag(name = "Example", description = "the Example API")
public interface ExampleApi {
/**
* GET /example/{exampleId}/ : Get example associated with this id
*
* @param exampleId the id of an example (required)
* @return The example associated with this id (status code 200)
* or The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). (status code 400)
* or Forbidden: the server is refusing action, you do not have the necessary permissions this resource (status code 403)
* or The server encountered an unexpected condition which prevented it from fulfilling the request (status code 500)
*/
@Operation(
operationId = "getExampleById",
summary = "Get example associated with this id",
tags = { "Example" },
responses = {
@ApiResponse(responseCode = "200", description = "The example associated with this id", content = {
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = ExampleSchema.class)))
}),
@ApiResponse(responseCode = "400", description = "The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)."),
@ApiResponse(responseCode = "403", description = "Forbidden: the server is refusing action, you do not have the necessary permissions this resource"),
@ApiResponse(responseCode = "500", description = "The server encountered an unexpected condition which prevented it from fulfilling the request")
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/example/{exampleId}/",
produces = { "application/json" }
)
ResponseEntity<List<ExampleSchema>> getExampleById(
@Parameter(name = "exampleId", description = "the id of an example", required = true, in = ParameterIn.PATH) @PathVariable("exampleId") ExampleSchema exampleId
);
}

View File

@@ -0,0 +1,133 @@
package model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.UUID;
import java.io.Serializable;
import java.time.OffsetDateTime;
import javax.validation.constraints.NotNull;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;
/**
* ExampleSchema
*/
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class ExampleSchema implements Serializable {
private static final long serialVersionUID = 1L;
private UUID id;
private String name;
private String description = null;
public ExampleSchema id(UUID id) {
this.id = id;
return this;
}
/**
* Get id
* @return id
*/
@Schema(name = "id", example = "b1e0773f-ef0c-43cf-a1df-52d17f4a3017", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("id")
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public ExampleSchema name(String name) {
this.name = name;
return this;
}
/**
* Get name
* @return name
*/
@Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ExampleSchema description(String description) {
this.description = description;
return this;
}
/**
* Get description
* @return description
*/
@Schema(name = "description", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ExampleSchema exampleSchema = (ExampleSchema) o;
return Objects.equals(this.id, exampleSchema.id) &&
Objects.equals(this.name, exampleSchema.name) &&
Objects.equals(this.description, exampleSchema.description);
}
@Override
public int hashCode() {
return Objects.hash(id, name, description);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ExampleSchema {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,3 @@
artifactId=example-api
groupId=com.example
version=1.0.0

View File

@@ -0,0 +1,3 @@
api/ApiUtil.class
model/ExampleSchema.class
api/ExampleApi.class

View File

@@ -0,0 +1,3 @@
/api/generated/example/java/example/src/main/java/api/ApiUtil.java
/api/generated/example/java/example/src/main/java/api/ExampleApi.java
/api/generated/example/java/example/src/main/java/model/ExampleSchema.java