-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add testcase for api/model suffix/prefix * Fix prefix/suffix
- Loading branch information
Showing
10 changed files
with
261 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package issue._414; | ||
|
||
@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") | ||
@io.micronaut.validation.Validated | ||
public interface ApiPrefixDefaultApiSuffix { | ||
|
||
@io.micronaut.http.annotation.Get("/doIt") | ||
io.micronaut.http.HttpResponse<Object> doIt(); | ||
} |
34 changes: 34 additions & 0 deletions
34
gen/main/java/issue/_414/ModelPrefixModelEnumModelSuffix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package issue._414; | ||
|
||
@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") | ||
public enum ModelPrefixModelEnumModelSuffix { | ||
|
||
FOO("foo"), | ||
BAR("bar"); | ||
|
||
public static final java.lang.String FOO_VALUE = "foo"; | ||
public static final java.lang.String BAR_VALUE = "bar"; | ||
|
||
private final java.lang.String value; | ||
|
||
private ModelPrefixModelEnumModelSuffix(java.lang.String value) { | ||
this.value = value; | ||
} | ||
|
||
@com.fasterxml.jackson.annotation.JsonCreator | ||
public static ModelPrefixModelEnumModelSuffix toEnum(java.lang.String value) { | ||
return toOptional(value).orElseThrow(() -> new IllegalArgumentException("Unknown value '" + value + "'.")); | ||
} | ||
|
||
public static java.util.Optional<ModelPrefixModelEnumModelSuffix> toOptional(java.lang.String value) { | ||
return java.util.Arrays | ||
.stream(values()) | ||
.filter(e -> e.value.equals(value)) | ||
.findAny(); | ||
} | ||
|
||
@com.fasterxml.jackson.annotation.JsonValue | ||
public java.lang.String getValue() { | ||
return value; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
gen/main/java/issue/_414/ModelPrefixModelObjectModelSuffix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package issue._414; | ||
|
||
@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") | ||
@io.micronaut.serde.annotation.Serdeable | ||
public class ModelPrefixModelObjectModelSuffix { | ||
|
||
@com.fasterxml.jackson.annotation.JsonProperty("a") | ||
@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) | ||
private java.lang.String a; | ||
|
||
// methods | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (object == this) { | ||
return true; | ||
} | ||
if (object == null || getClass() != object.getClass()) { | ||
return false; | ||
} | ||
ModelPrefixModelObjectModelSuffix other = (ModelPrefixModelObjectModelSuffix) object; | ||
return java.util.Objects.equals(a, other.a); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return java.util.Objects.hash(a); | ||
} | ||
|
||
@Override | ||
public java.lang.String toString() { | ||
return new java.lang.StringBuilder() | ||
.append("ModelPrefixModelObjectModelSuffix[") | ||
.append("a=").append(a) | ||
.append("]") | ||
.toString(); | ||
} | ||
|
||
// fluent | ||
|
||
public ModelPrefixModelObjectModelSuffix a(java.lang.String newA) { | ||
this.a = newA; | ||
return this; | ||
} | ||
|
||
// getter/setter | ||
|
||
public java.lang.String getA() { | ||
return a; | ||
} | ||
|
||
public void setA(java.lang.String newA) { | ||
this.a = newA; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
gen/test/java/issue/_414/ApiPrefixDefaultApiSuffixTestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package issue._414; | ||
|
||
/** Test client for {@link ApiPrefixDefaultApiSuffix}. **/ | ||
@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") | ||
@io.micronaut.http.client.annotation.Client("${micronaut.http.services.test.clientId:/}") | ||
public interface ApiPrefixDefaultApiSuffixTestClient { | ||
|
||
@io.micronaut.http.annotation.Get("/doIt") | ||
io.micronaut.http.HttpResponse<?> doIt(); | ||
} |
10 changes: 10 additions & 0 deletions
10
gen/test/java/issue/_414/ApiPrefixDefaultApiSuffixTestSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package issue._414; | ||
|
||
/** Test for {@link ApiPrefixDefaultApiSuffix}. */ | ||
@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") | ||
public interface ApiPrefixDefaultApiSuffixTestSpec { | ||
|
||
// doIt | ||
|
||
void doIt200() throws java.lang.Exception; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@-it</artifactId> | ||
<version>LOCAL-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>@project.artifactId@-it-issue-414</artifactId> | ||
|
||
<dependencies> | ||
|
||
<!-- micronaut --> | ||
<dependency> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-http-client</artifactId> | ||
</dependency> | ||
|
||
<!-- jackson --> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
</dependency> | ||
|
||
<!-- test --> | ||
<dependency> | ||
<groupId>io.micronaut.test</groupId> | ||
<artifactId>micronaut-test-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
|
||
<!-- generate sources from openapi spec --> | ||
<plugin> | ||
<groupId>org.openapitools</groupId> | ||
<artifactId>openapi-generator-maven-plugin</artifactId> | ||
<configuration> | ||
<inputSpec>@project.basedir@/src/test/resources/openapi/issue-414.yaml</inputSpec> | ||
<generateSupportingFiles>false</generateSupportingFiles> | ||
<apiNameSuffix>ApiSuffix</apiNameSuffix> | ||
<modelNamePrefix>ModelPrefix</modelNamePrefix> | ||
<modelNameSuffix>ModelSuffix</modelNameSuffix> | ||
<configOptions> | ||
<apiNamePrefix>ApiPrefix</apiNamePrefix> | ||
<generateConstants>false</generateConstants> | ||
<openApiNullable>false</openApiNullable> | ||
<useBeanValidation>false</useBeanValidation> | ||
<useGenericResponse>false</useGenericResponse> | ||
<serdeable>false</serdeable> | ||
</configOptions> | ||
<typeMappings> | ||
<typeMapping>Generated=</typeMapping> | ||
</typeMappings> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package codegen; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class GeneratedTest { | ||
|
||
@Test | ||
void load() { | ||
assertClass("codegen.ModelPrefixModelObjectModelSuffix"); | ||
assertClass("codegen.ModelPrefixModelEnumModelSuffix"); | ||
assertClass("codegen.server.ApiPrefixDefaultApiSuffix"); | ||
assertClass("codegen.server.ApiPrefixDefaultApiSuffixTestClient"); | ||
assertClass("codegen.server.ApiPrefixDefaultApiSuffixTestSpec"); | ||
} | ||
|
||
private static void assertClass(String name) { | ||
assertDoesNotThrow(() -> Class.forName(name), "Failed to load " + name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: Spec for <https://github.com/kokuwaio/micronaut-openapi-codegen/issues/414> | ||
version: "1" | ||
paths: | ||
/doIt: | ||
get: | ||
operationId: doIt | ||
responses: | ||
200: | ||
description: OK | ||
components: | ||
schemas: | ||
ModelObject: | ||
type: object | ||
properties: | ||
a: | ||
type: string | ||
ModelEnum: | ||
type: string | ||
enum: [foo, bar] |