[Micronaut] Add option to describe response wrappers (#12186)

* Minor refactor for Micronaut generators

* Add support for security roles in micronaut server generator

* Micronaut Server Generator refactor the x-roles String variable

* Add support for Micronaut HttpResponse wrapper

* Generate samples

* Optimize the usage of context-path for Micronaut server
This commit is contained in:
Andriy Dmytruk
2022-04-24 04:10:33 -04:00
committed by GitHub
parent bb4514b99d
commit 52d8a969ce
27 changed files with 311 additions and 170 deletions

View File

@@ -59,6 +59,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|parentVersion|parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|reactive|Make the responses use Reactor Mono as wrapper| |true|
|requiredPropertiesInConstructor|Allow only to create models with all the required properties provided in constructor| |true|
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|scmDeveloperConnection|SCM developer connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
@@ -74,6 +75,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useBeanValidation|Use BeanValidation API annotations| |true|
|useOptional|Use Optional container for optional parameters| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|wrapInHttpResponse|Wrap the response in HttpResponse object| |false|
## SUPPORTED VENDOR EXTENSIONS

View File

@@ -60,6 +60,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|parentVersion|parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|reactive|Make the responses use Reactor Mono as wrapper| |true|
|requiredPropertiesInConstructor|Allow only to create models with all the required properties provided in constructor| |true|
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|scmDeveloperConnection|SCM developer connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
@@ -76,6 +77,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useBeanValidation|Use BeanValidation API annotations| |true|
|useOptional|Use Optional container for optional parameters| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|wrapInHttpResponse|Wrap the response in HttpResponse object| |false|
## SUPPORTED VENDOR EXTENSIONS

View File

@@ -32,6 +32,8 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
public static final String OPT_DATE_LIBRARY_JAVA8_LOCAL_DATETIME = "java8-localdatetime";
public static final String OPT_DATE_FORMAT = "dateFormat";
public static final String OPT_DATETIME_FORMAT = "datetimeFormat";
public static final String OPT_REACTIVE = "reactive";
public static final String OPT_WRAP_IN_HTTP_RESPONSE = "wrapInHttpResponse";
protected String title;
protected boolean useBeanValidation;
@@ -39,7 +41,9 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
protected String buildTool;
protected String testTool;
protected boolean requiredPropertiesInConstructor = true;
protected String micronautVersion = "3.3.1";
protected String micronautVersion;
protected boolean reactive;
protected boolean wrapInHttpResponse;
public static final String CONTENT_TYPE_APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
public static final String CONTENT_TYPE_APPLICATION_JSON = "application/json";
@@ -58,7 +62,6 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
buildTool = OPT_BUILD_ALL;
testTool = OPT_TEST_JUNIT;
outputFolder = "generated-code/java-micronaut-client";
templateDir = "java-micronaut/client";
apiPackage = "org.openapitools.api";
modelPackage = "org.openapitools.model";
invokerPackage = "org.openapitools";
@@ -67,6 +70,9 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
apiDocPath = "docs/apis";
modelDocPath = "docs/models";
dateLibrary = OPT_DATE_LIBRARY_JAVA8;
micronautVersion = "3.3.1";
reactive = true;
wrapInHttpResponse = false;
// Set implemented features for user information
modifyFeatureSet(features -> features
@@ -100,9 +106,11 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations", useBeanValidation));
cliOptions.add(CliOption.newBoolean(USE_OPTIONAL, "Use Optional container for optional parameters", useOptional));
cliOptions.add(CliOption.newBoolean(OPT_REQUIRED_PROPERTIES_IN_CONSTRUCTOR, "Allow only to create models with all the required properties provided in constructor", requiredPropertiesInConstructor));
cliOptions.add(CliOption.newBoolean(OPT_REACTIVE, "Make the responses use Reactor Mono as wrapper", reactive));
cliOptions.add(CliOption.newBoolean(OPT_WRAP_IN_HTTP_RESPONSE, "Wrap the response in HttpResponse object", wrapInHttpResponse));
CliOption buildToolOption = new CliOption(OPT_BUILD, "Specify for which build tool to generate files").defaultValue(buildTool);
Map buildToolOptionMap = new HashMap<String, String>();
Map<String, String> buildToolOptionMap = new HashMap<>();
buildToolOptionMap.put(OPT_BUILD_GRADLE, "Gradle configuration is generated for the project");
buildToolOptionMap.put(OPT_BUILD_MAVEN, "Maven configuration is generated for the project");
buildToolOptionMap.put(OPT_BUILD_ALL, "Both Gradle and Maven configurations are generated");
@@ -110,7 +118,7 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
cliOptions.add(buildToolOption);
CliOption testToolOption = new CliOption(OPT_TEST, "Specify which test tool to generate files for").defaultValue(testTool);
Map testToolOptionMap = new HashMap<String, String>();
Map<String, String> testToolOptionMap = new HashMap<>();
testToolOptionMap.put(OPT_TEST_JUNIT, "Use JUnit as test tool");
testToolOptionMap.put(OPT_TEST_SPOCK, "Use Spock as test tool");
testToolOption.setEnum(testToolOptionMap);
@@ -172,6 +180,16 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
}
writePropertyBack(OPT_REQUIRED_PROPERTIES_IN_CONSTRUCTOR, requiredPropertiesInConstructor);
if (additionalProperties.containsKey(OPT_REACTIVE)) {
this.reactive = convertPropertyToBoolean(OPT_REACTIVE);
}
writePropertyBack(OPT_REACTIVE, reactive);
if (additionalProperties.containsKey(OPT_WRAP_IN_HTTP_RESPONSE)) {
this.wrapInHttpResponse = convertPropertyToBoolean(OPT_WRAP_IN_HTTP_RESPONSE);
}
writePropertyBack(OPT_WRAP_IN_HTTP_RESPONSE, wrapInHttpResponse);
// Get enum properties
if (additionalProperties.containsKey(OPT_BUILD)) {
switch ((String) additionalProperties.get(OPT_BUILD)) {
@@ -363,14 +381,14 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
allowableValues = (List<Object>) m.allowableValues.get("values");
}
example = getExampleValue(m.defaultValue, null, m.classname, true,
allowableValues, null, null, m.requiredVars, false);
allowableValues, null, null, m.requiredVars, false, false);
groovyExample = getExampleValue(m.defaultValue, null, m.classname, true,
allowableValues, null, null, m.requiredVars, true);
allowableValues, null, null, m.requiredVars, true, false);
} else {
example = getExampleValue(null, null, op.returnType, false, null,
op.returnBaseType, null, null, false);
op.returnBaseType, null, null, false, false);
groovyExample = getExampleValue(null, null, op.returnType, false, null,
op.returnBaseType, null, null, true);
op.returnBaseType, null, null, true, false);
}
op.vendorExtensions.put("example", example);
op.vendorExtensions.put("groovyExample", groovyExample);
@@ -439,7 +457,7 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
return getExampleValue(p.defaultValue, p.example, p.dataType, p.isModel, allowableValues,
p.items == null ? null : p.items.dataType,
p.items == null ? null : p.items.defaultValue,
p.requiredVars, groovy);
p.requiredVars, groovy, false);
}
protected String getPropertyExampleValue(CodegenProperty p, boolean groovy) {
@@ -448,12 +466,12 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
return getExampleValue(p.defaultValue, p.example, p.dataType, p.isModel, allowableValues,
p.items == null ? null : p.items.dataType,
p.items == null ? null : p.items.defaultValue,
null, groovy);
null, groovy, true);
}
public String getExampleValue(
String defaultValue, String example, String dataType, Boolean isModel, List<Object> allowableValues,
String itemsType, String itemsExample, List<CodegenProperty> requiredVars, boolean groovy
String itemsType, String itemsExample, List<CodegenProperty> requiredVars, boolean groovy, boolean isProperty
) {
example = defaultValue != null ? defaultValue : example;
String containerType = dataType == null ? null : dataType.split("<")[0];
@@ -490,6 +508,9 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
if (value == null || !allowableValues.contains(value)) {
value = allowableValues.get(0);
}
if (isProperty) {
dataType = importMapping.getOrDefault(dataType, modelPackage + '.' + dataType);
}
example = dataType + ".fromValue(\"" + value + "\")";
} else if ((isModel != null && isModel) || (isModel == null && !languageSpecificPrimitives.contains(dataType))) {
if (requiredVars == null) {
@@ -497,6 +518,9 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
} else {
if (requiredPropertiesInConstructor) {
StringBuilder builder = new StringBuilder();
if (isProperty) {
dataType = importMapping.getOrDefault(dataType, modelPackage + '.' + dataType);
}
builder.append("new ").append(dataType).append("(");
for (int i = 0; i < requiredVars.size(); ++i) {
if (i != 0) {

View File

@@ -8,7 +8,12 @@ import io.micronaut.http.client.annotation.Client;
import {{invokerPackage}}.auth.Authorization;
{{/configureAuth}}
import io.micronaut.core.convert.format.Format;
{{#reactive}}
import reactor.core.publisher.Mono;
{{/reactive}}
{{#wrapInHttpResponse}}
import io.micronaut.http.HttpResponse;
{{/wrapInHttpResponse}}
{{#imports}}import {{import}};
{{/imports}}
import javax.annotation.Generated;
@@ -63,9 +68,9 @@ public interface {{classname}} {
{{/authMethods}}
{{/configureAuth}}
{{!the method definition}}
{{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} {{nickname}}({{^allParams}});{{/allParams}}{{#allParams}}
{{>common/operationReturnType}} {{nickname}}({{#allParams}}
{{>client/params/queryParams}}{{>client/params/pathParams}}{{>client/params/headerParams}}{{>client/params/bodyParams}}{{>client/params/formParams}}{{>client/params/cookieParams}}{{^-last}}, {{/-last}}{{#-last}}
);{{/-last}}{{/allParams}}
{{/-last}}{{/allParams}});
{{/operation}}
{{/operations}}
}

View File

@@ -5,12 +5,17 @@ package {{package}}
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import spock.lang.Specification
import jakarta.inject.Inject
import reactor.core.publisher.Mono
import spock.lang.Ignore
{{#wrapInHttpResponse}}
import io.micronaut.http.HttpResponse
{{/wrapInHttpResponse}}
{{^fullJavaUtil}}
import java.util.Arrays
import java.util.ArrayList
import java.util.HashMap
import java.util.List
import java.util.Map
import java.util.HashSet
{{/fullJavaUtil}}
@@ -31,15 +36,23 @@ class {{classname}}Spec extends Specification {
* {{notes}}
{{/notes}}
*/
@Ignore("Not Implemented")
void '{{operationId}}() test'() {
given:
{{#allParams}}
{{{dataType}}} {{paramName}} = null
{{{dataType}}} {{paramName}} = {{{vendorExtensions.groovyExample}}}
{{/allParams}}
// {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).block()
// {{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} asyncResponse = api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
expect:
when:
{{#wrapInHttpResponse}}
HttpResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> response = api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#reactive}}.block(){{/reactive}}{{#returnType}}
{{{returnType}}} body = response.body(){{/returnType}}
{{/wrapInHttpResponse}}
{{^wrapInHttpResponse}}
{{#returnType}}{{{returnType}}} body = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#reactive}}.block(){{/reactive}}
{{/wrapInHttpResponse}}
then:
true
// TODO: test validations
}

View File

@@ -5,14 +5,18 @@ package {{package}};
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import jakarta.inject.Inject;
import reactor.core.publisher.Mono;
{{#wrapInHttpResponse}}
import io.micronaut.http.HttpResponse;
{{/wrapInHttpResponse}}
{{^fullJavaUtil}}
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashSet;
{{/fullJavaUtil}}
@@ -34,13 +38,24 @@ public class {{classname}}Test {
{{/notes}}
*/
@Test
@Disabled("Not Implemented")
public void {{operationId}}Test() {
// given
{{#allParams}}
{{{dataType}}} {{paramName}} = null;
{{{dataType}}} {{paramName}} = {{{example}}};
{{/allParams}}
// {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).block();
// {{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} asyncResponse = api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
// TODO: test validations
// when
{{#wrapInHttpResponse}}
HttpResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> response = api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#reactive}}.block(){{/reactive}};{{#returnType}}
{{{returnType}}} body = response.body();{{/returnType}}
{{/wrapInHttpResponse}}
{{^wrapInHttpResponse}}
{{#returnType}}{{{returnType}}} body = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#reactive}}.block(){{/reactive}};
{{/wrapInHttpResponse}}
// then
// TODO implement the {{operationId}}Test()
}
{{/operation}}{{/operations}}

View File

@@ -1,7 +1,6 @@
{{!CLIENT CONFIGURATION}}
{{#client}}
base-path: "{{{basePath}}}/"
context-path: "{{{contextPath}}}/"
micronaut:
application:
@@ -56,13 +55,13 @@ micronaut:
{{/client}}
{{!SERVER CONFIGURATION}}
{{#server}}
context-path: "{{{contextPath}}}/"
micronaut:
application:
name: {{artifactId}}
server:
port: 8080
port: 8080{{#contextPath}}
context-path: "{{{contextPath}}}"{{/contextPath}}
security:
# authentication: bearer | cookie | session | idtoken
{{/server}}

View File

@@ -40,7 +40,9 @@ dependencies {
implementation("io.micronaut.security:micronaut-security")
implementation("io.micronaut.security:micronaut-security-oauth2")
{{/useAuth}}
{{#reactive}}
implementation("io.micronaut.reactor:micronaut-reactor")
{{/reactive}}
implementation("io.swagger:swagger-annotations:1.5.9")
runtimeOnly("ch.qos.logback:logback-classic")
}

View File

@@ -98,11 +98,13 @@
<artifactId>micronaut-runtime</artifactId>
<scope>compile</scope>
</dependency>
{{#reactive}}
<dependency>
<groupId>io.micronaut.reactor</groupId>
<artifactId>micronaut-reactor</artifactId>
<scope>compile</scope>
</dependency>
{{/reactive}}
{{#useAuth}}
<dependency>
<groupId>io.micronaut.security</groupId>

View File

@@ -0,0 +1,12 @@
{{!begin reactive
}}{{#reactive}}Mono<{{/reactive}}{{!
begin wrapInHttpResponse
}}{{#wrapInHttpResponse}}HttpResponse<{{/wrapInHttpResponse}}{{!
return type
}}{{#returnType}}{{{returnType}}}{{/returnType}}{{!
no return type
}}{{^returnType}}{{#reactive}}Void{{/reactive}}{{^reactive}}{{#wrapInHttpResponse}}Void{{/wrapInHttpResponse}}{{/reactive}}{{^reactive}}{{^wrapInHttpResponse}}void{{/wrapInHttpResponse}}{{/reactive}}{{/returnType}}{{!
end wrapInHttpResponse
}}{{#wrapInHttpResponse}}>{{/wrapInHttpResponse}}{{!
end reactive
}}{{#reactive}}>{{/reactive}}

View File

@@ -8,7 +8,12 @@ import io.micronaut.core.convert.format.Format;
import io.micronaut.security.annotation.Secured;
import io.micronaut.security.rules.SecurityRule;
{{/useAuth}}
{{#reactive}}
import reactor.core.publisher.Mono;
{{/reactive}}
{{#wrapInHttpResponse}}
import io.micronaut.http.HttpResponse;
{{/wrapInHttpResponse}}
{{#imports}}
import {{import}};
{{/imports}}
@@ -30,7 +35,7 @@ import io.swagger.annotations.*;
{{>common/generatedAnnotation}}
{{^generateControllerAsAbstract}}
@Controller("${context-path}")
@Controller
{{/generateControllerAsAbstract}}
public {{#generateControllerAsAbstract}}abstract {{/generateControllerAsAbstract}}class {{classname}} {
{{#operations}}
@@ -95,7 +100,7 @@ public {{#generateControllerAsAbstract}}abstract {{/generateControllerAsAbstract
@Secured({{openbrace}}{{#vendorExtensions.x-roles}}{{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-roles}}{{closebrace}})
{{/useAuth}}
{{!the method definition}}
public {{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} {{nickname}}{{#generateControllerAsAbstract}}Api{{/generateControllerAsAbstract}}({{#allParams}}
public {{>common/operationReturnType}} {{nickname}}{{#generateControllerAsAbstract}}Api{{/generateControllerAsAbstract}}({{#allParams}}
{{>server/params/queryParams}}{{>server/params/pathParams}}{{>server/params/headerParams}}{{>server/params/bodyParams}}{{>server/params/formParams}}{{>server/params/cookieParams}}{{^-last}}, {{/-last}}{{#-last}}
{{/-last}}{{/allParams}}) {
{{^generateControllerAsAbstract}}
@@ -114,7 +119,7 @@ public {{#generateControllerAsAbstract}}abstract {{/generateControllerAsAbstract
*
* This method will be delegated to when the controller gets a request
*/
public abstract {{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
public abstract {{>common/operationReturnType}} {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
{{/generateControllerAsAbstract}}
{{^-last}}

View File

@@ -2,7 +2,12 @@
package {{controllerPackage}};
import io.micronaut.http.annotation.Controller;
{{#reactive}}
import reactor.core.publisher.Mono;
{{/reactive}}
{{#wrapInHttpResponse}}
import io.micronaut.http.HttpResponse;
{{/wrapInHttpResponse}}
import {{package}}.{{classname}};
{{#imports}}
import {{import}};
@@ -18,13 +23,13 @@ import java.util.Arrays;
{{/fullJavaUtil}}
@Controller("${context-path}")
@Controller
public class {{controllerClassname}} extends {{classname}} {
{{#operations}}
{{#operation}}
{{!the method definition}}
@Override
public {{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
public {{>common/operationReturnType}} {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
{{>server/controllerOperationBody}} }
{{^-last}}

View File

@@ -1,8 +1,7 @@
{{^generateControllerFromExamples}}
{{!The body needs to be implemented by user}}
// TODO implement {{nickname}}() body;
{{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} result = Mono.empty();
return result;
// TODO implement {{nickname}}();
{{#reactive}}{{#wrapInHttpResponse}}return Mono.fromCallable(HttpResponse::ok);{{/wrapInHttpResponse}}{{^wrapInHttpResponse}}return Mono.empty();{{/wrapInHttpResponse}}{{/reactive}}{{^reactive}}{{#wrapInHttpResponse}}return HttpResponse.ok();{{/wrapInHttpResponse}}{{^wrapInHttpResponse}}{{#returnType}}return null;{{/returnType}}{{/wrapInHttpResponse}}{{/reactive}}
{{/generateControllerFromExamples}}
{{#generateControllerFromExamples}}
{{!The body is generated to verify that example values are passed correctly}}
@@ -12,6 +11,27 @@
assert {{paramName}}.equals({{paramName}}Expected) : "The parameter {{paramName}} was expected to match its example value";
{{/isFile}}
{{/allParams}}
return Mono.fromCallable(() -> {{^returnType}}""{{/returnType}}{{#returnType}}{{#vendorExtensions.example}}{{{vendorExtensions.example}}}{{/vendorExtensions.example}}{{^vendorExtensions.example}}null{{/vendorExtensions.example}}{{/returnType}});
{{!
return type present
}}{{#returnType}}return {{!
reactive start
}}{{#reactive}}Mono.fromCallable(() -> {{/reactive}}{{!
wrapInHttpResponse start
}}{{#wrapInHttpResponse}}HttpResponse.ok({{/wrapInHttpResponse}}{{!
body
}}{{#vendorExtensions.example}}{{{vendorExtensions.example}}}{{/vendorExtensions.example}}{{^vendorExtensions.example}}{{^wrapInHttpResponse}}null{{/wrapInHttpResponse}}{{/vendorExtensions.example}}{{!
wrapInHttpResponse end
}}{{#wrapInHttpResponse}}){{/wrapInHttpResponse}}{{!
reactive end
}}{{#reactive}}){{/reactive}};{{/returnType}}{{!
return type not present
}}{{^returnType}}{{!
reactive
}}{{#reactive}}return {{!
wrapInHttpResponse
}}{{#wrapInHttpResponse}}Mono.fromCallable(HttpResponse::ok){{/wrapInHttpResponse}}{{^wrapInHttpResponse}}Mono.fromCallable(() -> null){{/wrapInHttpResponse}};{{/reactive}}{{!
not reactive
}}{{^reactive}}{{!
wrapInHttpResponse
}}{{#wrapInHttpResponse}}return HttpResponse.ok();{{/wrapInHttpResponse}}{{/reactive}}{{/returnType}}
{{/generateControllerFromExamples}}

View File

@@ -19,7 +19,9 @@ import io.micronaut.core.type.Argument
import jakarta.inject.Inject
import spock.lang.Specification
import spock.lang.Ignore
{{#reactive}}
import reactor.core.publisher.Mono
{{/reactive}}
import java.io.File
import java.io.FileReader
@@ -34,7 +36,7 @@ class {{classname}}Spec extends Specification {
EmbeddedServer server
@Inject
@Client('${context-path}')
@Client
HttpClient client
@Inject
@@ -63,7 +65,7 @@ class {{classname}}Spec extends Specification {
{{/allParams}}
when:
{{#returnType}}{{{returnType}}} result = {{/returnType}}controller.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).block()
{{#returnType}}{{{returnType}}} result = {{/returnType}}controller.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#reactive}}.block(){{/reactive}}{{#wrapInHttpResponse}}.body(){{/wrapInHttpResponse}}
then:
{{^generateControllerFromExamples}}

View File

@@ -20,7 +20,9 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Assertions;
import jakarta.inject.Inject;
{{#reactive}}
import reactor.core.publisher.Mono;
{{/reactive}}
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
@@ -44,7 +46,7 @@ public class {{classname}}Test {
EmbeddedServer server;
@Inject
@Client("${context-path}")
@Client
HttpClient client;
@Inject
@@ -74,7 +76,7 @@ public class {{classname}}Test {
{{/allParams}}
// when
{{#returnType}}{{{returnType}}} result = {{/returnType}}controller.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).block();
{{#returnType}}{{{returnType}}} result = {{/returnType}}controller.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#reactive}}.block(){{/reactive}}{{#wrapInHttpResponse}}.body(){{/wrapInHttpResponse}};
// then
{{^generateControllerFromExamples}}

View File

@@ -237,4 +237,56 @@ public class MicronautServerCodegenTest extends AbstractMicronautCodegenTest {
assertFileContainsRegex(controllerPath + "UsersController.java", "IS_ANONYMOUS[^;]{0,100}getUserProfile");
assertFileContainsRegex(controllerPath + "UsersController.java", "IS_AUTHENTICATED[^;]{0,100}updateProfile");
}
@Test
public void doGenerateMonoWrapHttpResponse() {
JavaMicronautServerCodegen codegen = new JavaMicronautServerCodegen();
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_REACTIVE, "true");
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_WRAP_IN_HTTP_RESPONSE, "true");
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
// Constructor should have properties
String controllerPath = outputPath + "src/main/java/org/openapitools/controller/";
assertFileContains(controllerPath + "PetController.java", "Mono<HttpResponse<Pet>>");
}
@Test
public void doGenerateMono() {
JavaMicronautServerCodegen codegen = new JavaMicronautServerCodegen();
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_REACTIVE, "true");
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_WRAP_IN_HTTP_RESPONSE, "false");
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
// Constructor should have properties
String controllerPath = outputPath + "src/main/java/org/openapitools/controller/";
assertFileContains(controllerPath + "PetController.java", "Mono<Pet>");
assertFileNotContains(controllerPath + "PetController.java", "HttpResponse");
}
@Test
public void doGenerateWrapHttpResponse() {
JavaMicronautServerCodegen codegen = new JavaMicronautServerCodegen();
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_REACTIVE, "false");
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_WRAP_IN_HTTP_RESPONSE, "true");
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
// Constructor should have properties
String controllerPath = outputPath + "src/main/java/org/openapitools/controller/";
assertFileContains(controllerPath + "PetController.java", "HttpResponse<Pet>");
assertFileNotContains(controllerPath + "PetController.java", "Mono");
}
@Test
public void doGenerateNoMonoNoWrapHttpResponse() {
JavaMicronautServerCodegen codegen = new JavaMicronautServerCodegen();
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_REACTIVE, "false");
codegen.additionalProperties().put(JavaMicronautServerCodegen.OPT_WRAP_IN_HTTP_RESPONSE, "false");
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.MODELS, CodegenConstants.APIS);
// Constructor should have properties
String controllerPath = outputPath + "src/main/java/org/openapitools/controller/";
assertFileContains(controllerPath + "PetController.java", "Pet");
assertFileNotContains(controllerPath + "PetController.java", "Mono");
assertFileNotContains(controllerPath + "PetController.java", "HttpResponse");
}
}

View File

@@ -42,5 +42,5 @@ public interface AnotherFakeApi {
@Consumes(value={"application/json"})
Mono<ModelClient> call123testSpecialTags(
@Body @NotNull @Valid ModelClient _body
);
);
}

View File

@@ -47,9 +47,9 @@ public interface FakeApi {
@Post(uri="/fake/create_xml_item")
@Produces(value={"application/xml"})
@Consumes(value={"application/json"})
Mono<Object> createXmlItem(
Mono<Void> createXmlItem(
@Body @NotNull @Valid XmlItem xmlItem
);
);
/**
* Test serialization of outer boolean types
*
@@ -61,7 +61,7 @@ public interface FakeApi {
@Consumes(value={"*/*"})
Mono<Boolean> fakeOuterBooleanSerialize(
@Body @Nullable Boolean _body
);
);
/**
* Test serialization of object with outer number type
*
@@ -73,7 +73,7 @@ public interface FakeApi {
@Consumes(value={"*/*"})
Mono<OuterComposite> fakeOuterCompositeSerialize(
@Body @Nullable @Valid OuterComposite _body
);
);
/**
* Test serialization of outer number types
*
@@ -85,7 +85,7 @@ public interface FakeApi {
@Consumes(value={"*/*"})
Mono<BigDecimal> fakeOuterNumberSerialize(
@Body @Nullable BigDecimal _body
);
);
/**
* Test serialization of outer string types
*
@@ -97,7 +97,7 @@ public interface FakeApi {
@Consumes(value={"*/*"})
Mono<String> fakeOuterStringSerialize(
@Body @Nullable String _body
);
);
/**
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.
*
@@ -106,9 +106,9 @@ public interface FakeApi {
@Put(uri="/fake/body-with-file-schema")
@Produces(value={"application/json"})
@Consumes(value={"application/json"})
Mono<Object> testBodyWithFileSchema(
Mono<Void> testBodyWithFileSchema(
@Body @NotNull @Valid FileSchemaTestClass _body
);
);
/**
* testBodyWithQueryParams
*
@@ -118,10 +118,10 @@ public interface FakeApi {
@Put(uri="/fake/body-with-query-params")
@Produces(value={"application/json"})
@Consumes(value={"application/json"})
Mono<Object> testBodyWithQueryParams(
Mono<Void> testBodyWithQueryParams(
@QueryValue(value="query") @NotNull String query,
@Body @NotNull @Valid User _body
);
);
/**
* To test \&quot;client\&quot; model
* To test \&quot;client\&quot; model
@@ -134,7 +134,7 @@ public interface FakeApi {
@Consumes(value={"application/json"})
Mono<ModelClient> testClientModel(
@Body @NotNull @Valid ModelClient _body
);
);
/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -157,7 +157,7 @@ public interface FakeApi {
@Post(uri="/fake")
@Produces(value={"application/x-www-form-urlencoded"})
@Consumes(value={"application/json"})
Mono<Object> testEndpointParameters(
Mono<Void> testEndpointParameters(
@NotNull @DecimalMin("32.1") @DecimalMax("543.2") BigDecimal number,
@NotNull @DecimalMin("67.8") @DecimalMax("123.4") Double _double,
@NotNull @Pattern(regexp="^[A-Z].*") String patternWithoutDelimiter,
@@ -172,7 +172,7 @@ public interface FakeApi {
@Nullable @Format("yyyy-MM-dd'T'HH:mm:ss.SSSXXXX") OffsetDateTime dateTime,
@Nullable @Size(min=10, max=64) String password,
@Nullable String paramCallback
);
);
/**
* To test enum parameters
* To test enum parameters
@@ -189,7 +189,7 @@ public interface FakeApi {
@Get(uri="/fake")
@Produces(value={"application/x-www-form-urlencoded"})
@Consumes(value={"application/json"})
Mono<Object> testEnumParameters(
Mono<Void> testEnumParameters(
@Header(name="enum_header_string_array") @Nullable List<String> enumHeaderStringArray,
@Header(name="enum_header_string", defaultValue="-efg") @Nullable String enumHeaderString,
@QueryValue(value="enum_query_string_array") @Nullable List<String> enumQueryStringArray,
@@ -198,7 +198,7 @@ public interface FakeApi {
@QueryValue(value="enum_query_double") @Nullable Double enumQueryDouble,
@Nullable List<String> enumFormStringArray,
@Nullable String enumFormString
);
);
/**
* Fake endpoint to test group parameters (optional)
* Fake endpoint to test group parameters (optional)
@@ -212,14 +212,14 @@ public interface FakeApi {
*/
@Delete(uri="/fake")
@Consumes(value={"application/json"})
Mono<Object> testGroupParameters(
Mono<Void> testGroupParameters(
@QueryValue(value="required_string_group") @NotNull Integer requiredStringGroup,
@Header(name="required_boolean_group") @NotNull Boolean requiredBooleanGroup,
@QueryValue(value="required_int64_group") @NotNull Long requiredInt64Group,
@QueryValue(value="string_group") @Nullable Integer stringGroup,
@Header(name="boolean_group") @Nullable Boolean booleanGroup,
@QueryValue(value="int64_group") @Nullable Long int64Group
);
);
/**
* test inline additionalProperties
*
@@ -228,9 +228,9 @@ public interface FakeApi {
@Post(uri="/fake/inline-additionalProperties")
@Produces(value={"application/json"})
@Consumes(value={"application/json"})
Mono<Object> testInlineAdditionalProperties(
Mono<Void> testInlineAdditionalProperties(
@Body @NotNull Map<String, String> param
);
);
/**
* test json serialization of form data
*
@@ -240,10 +240,10 @@ public interface FakeApi {
@Get(uri="/fake/jsonFormData")
@Produces(value={"application/x-www-form-urlencoded"})
@Consumes(value={"application/json"})
Mono<Object> testJsonFormData(
Mono<Void> testJsonFormData(
@NotNull String param,
@NotNull String param2
);
);
/**
* To test the collection format in query parameters
*
@@ -255,11 +255,11 @@ public interface FakeApi {
*/
@Put(uri="/fake/test-query-parameters")
@Consumes(value={"application/json"})
Mono<Object> testQueryParameterCollectionFormat(
Mono<Void> testQueryParameterCollectionFormat(
@QueryValue(value="pipe") @NotNull List<String> pipe,
@QueryValue(value="ioutil") @NotNull List<String> ioutil,
@QueryValue(value="http") @NotNull List<String> http,
@QueryValue(value="url") @NotNull List<String> url,
@QueryValue(value="context") @NotNull List<String> context
);
);
}

View File

@@ -42,5 +42,5 @@ public interface FakeClassnameTags123Api {
@Consumes(value={"application/json"})
Mono<ModelClient> testClassname(
@Body @NotNull @Valid ModelClient _body
);
);
}

View File

@@ -41,9 +41,9 @@ public interface PetApi {
@Post(uri="/pet")
@Produces(value={"application/json"})
@Consumes(value={"application/json"})
Mono<Object> addPet(
Mono<Void> addPet(
@Body @NotNull @Valid Pet _body
);
);
/**
* Deletes a pet
*
@@ -52,10 +52,10 @@ public interface PetApi {
*/
@Delete(uri="/pet/{petId}")
@Consumes(value={"application/json"})
Mono<Object> deletePet(
Mono<Void> deletePet(
@PathVariable(name="petId") @NotNull Long petId,
@Header(name="api_key") @Nullable String apiKey
);
);
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
@@ -67,7 +67,7 @@ public interface PetApi {
@Consumes(value={"application/json"})
Mono<List<Pet>> findPetsByStatus(
@QueryValue(value="status") @NotNull List<String> status
);
);
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@@ -79,7 +79,7 @@ public interface PetApi {
@Consumes(value={"application/json"})
Mono<Set<Pet>> findPetsByTags(
@QueryValue(value="tags") @NotNull Set<String> tags
);
);
/**
* Find pet by ID
* Returns a single pet
@@ -91,7 +91,7 @@ public interface PetApi {
@Consumes(value={"application/json"})
Mono<Pet> getPetById(
@PathVariable(name="petId") @NotNull Long petId
);
);
/**
* Update an existing pet
*
@@ -100,9 +100,9 @@ public interface PetApi {
@Put(uri="/pet")
@Produces(value={"application/json"})
@Consumes(value={"application/json"})
Mono<Object> updatePet(
Mono<Void> updatePet(
@Body @NotNull @Valid Pet _body
);
);
/**
* Updates a pet in the store with form data
*
@@ -113,11 +113,11 @@ public interface PetApi {
@Post(uri="/pet/{petId}")
@Produces(value={"application/x-www-form-urlencoded"})
@Consumes(value={"application/json"})
Mono<Object> updatePetWithForm(
Mono<Void> updatePetWithForm(
@PathVariable(name="petId") @NotNull Long petId,
@Nullable String name,
@Nullable String status
);
);
/**
* uploads an image
*
@@ -133,7 +133,7 @@ public interface PetApi {
@PathVariable(name="petId") @NotNull Long petId,
@Nullable String additionalMetadata,
@Nullable File _file
);
);
/**
* uploads an image (required)
*
@@ -149,5 +149,5 @@ public interface PetApi {
@PathVariable(name="petId") @NotNull Long petId,
@NotNull File requiredFile,
@Nullable String additionalMetadata
);
);
}

View File

@@ -38,9 +38,9 @@ public interface StoreApi {
*/
@Delete(uri="/store/order/{order_id}")
@Consumes(value={"application/json"})
Mono<Object> deleteOrder(
Mono<Void> deleteOrder(
@PathVariable(name="order_id") @NotNull String orderId
);
);
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
@@ -61,7 +61,7 @@ public interface StoreApi {
@Consumes(value={"application/json"})
Mono<Order> getOrderById(
@PathVariable(name="order_id") @NotNull @Min(1L) @Max(5L) Long orderId
);
);
/**
* Place an order for a pet
*
@@ -73,5 +73,5 @@ public interface StoreApi {
@Consumes(value={"application/json"})
Mono<Order> placeOrder(
@Body @NotNull @Valid Order _body
);
);
}

View File

@@ -40,9 +40,9 @@ public interface UserApi {
@Post(uri="/user")
@Produces(value={"*/*"})
@Consumes(value={"application/json"})
Mono<Object> createUser(
Mono<Void> createUser(
@Body @NotNull @Valid User _body
);
);
/**
* Creates list of users with given input array
*
@@ -51,9 +51,9 @@ public interface UserApi {
@Post(uri="/user/createWithArray")
@Produces(value={"*/*"})
@Consumes(value={"application/json"})
Mono<Object> createUsersWithArrayInput(
Mono<Void> createUsersWithArrayInput(
@Body @NotNull List<User> _body
);
);
/**
* Creates list of users with given input array
*
@@ -62,9 +62,9 @@ public interface UserApi {
@Post(uri="/user/createWithList")
@Produces(value={"*/*"})
@Consumes(value={"application/json"})
Mono<Object> createUsersWithListInput(
Mono<Void> createUsersWithListInput(
@Body @NotNull List<User> _body
);
);
/**
* Delete user
* This can only be done by the logged in user.
@@ -73,9 +73,9 @@ public interface UserApi {
*/
@Delete(uri="/user/{username}")
@Consumes(value={"application/json"})
Mono<Object> deleteUser(
Mono<Void> deleteUser(
@PathVariable(name="username") @NotNull String username
);
);
/**
* Get user by user name
*
@@ -86,7 +86,7 @@ public interface UserApi {
@Consumes(value={"application/json"})
Mono<User> getUserByName(
@PathVariable(name="username") @NotNull String username
);
);
/**
* Logs user into the system
*
@@ -99,14 +99,14 @@ public interface UserApi {
Mono<String> loginUser(
@QueryValue(value="username") @NotNull String username,
@QueryValue(value="password") @NotNull String password
);
);
/**
* Logs out current logged in user session
*
*/
@Get(uri="/user/logout")
@Consumes(value={"application/json"})
Mono<Object> logoutUser();
Mono<Void> logoutUser();
/**
* Updated user
* This can only be done by the logged in user.
@@ -117,8 +117,8 @@ public interface UserApi {
@Put(uri="/user/{username}")
@Produces(value={"*/*"})
@Consumes(value={"application/json"})
Mono<Object> updateUser(
Mono<Void> updateUser(
@PathVariable(name="username") @NotNull String username,
@Body @NotNull @Valid User _body
);
);
}

View File

@@ -1,5 +1,4 @@
base-path: "http://petstore.swagger.io:80/v2/"
context-path: "/v2/"
micronaut:
application:

View File

@@ -29,7 +29,7 @@ import javax.validation.constraints.*;
import io.swagger.annotations.*;
@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen")
@Controller("${context-path}")
@Controller
public class PetController {
/**
* Add a new pet to the store
@@ -59,9 +59,8 @@ public class PetController {
public Mono<Pet> addPet(
@Body @NotNull @Valid Pet pet
) {
// TODO implement addPet() body;
Mono<Pet> result = Mono.empty();
return result;
// TODO implement addPet();
return Mono.empty();
}
/**
@@ -86,13 +85,12 @@ public class PetController {
@ApiResponse(code = 400, message = "Invalid pet value")})
@Delete(uri="/pet/{petId}")
@Produces(value = {})
public Mono<Object> deletePet(
public Mono<Void> deletePet(
@PathVariable(value="petId") @NotNull Long petId,
@Header(value="api_key") @Nullable String apiKey
) {
// TODO implement deletePet() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement deletePet();
return Mono.empty();
}
/**
@@ -122,9 +120,8 @@ public class PetController {
public Mono<List<Pet>> findPetsByStatus(
@QueryValue(value="status") @NotNull List<String> status
) {
// TODO implement findPetsByStatus() body;
Mono<List<Pet>> result = Mono.empty();
return result;
// TODO implement findPetsByStatus();
return Mono.empty();
}
/**
@@ -154,9 +151,8 @@ public class PetController {
public Mono<List<Pet>> findPetsByTags(
@QueryValue(value="tags") @NotNull List<String> tags
) {
// TODO implement findPetsByTags() body;
Mono<List<Pet>> result = Mono.empty();
return result;
// TODO implement findPetsByTags();
return Mono.empty();
}
/**
@@ -184,9 +180,8 @@ public class PetController {
public Mono<Pet> getPetById(
@PathVariable(value="petId") @NotNull Long petId
) {
// TODO implement getPetById() body;
Mono<Pet> result = Mono.empty();
return result;
// TODO implement getPetById();
return Mono.empty();
}
/**
@@ -219,9 +214,8 @@ public class PetController {
public Mono<Pet> updatePet(
@Body @NotNull @Valid Pet pet
) {
// TODO implement updatePet() body;
Mono<Pet> result = Mono.empty();
return result;
// TODO implement updatePet();
return Mono.empty();
}
/**
@@ -248,14 +242,13 @@ public class PetController {
@Post(uri="/pet/{petId}")
@Produces(value = {})
@Consumes(value = {"application/x-www-form-urlencoded"})
public Mono<Object> updatePetWithForm(
public Mono<Void> updatePetWithForm(
@PathVariable(value="petId") @NotNull Long petId,
@Nullable String name,
@Nullable String status
) {
// TODO implement updatePetWithForm() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement updatePetWithForm();
return Mono.empty();
}
/**
@@ -289,8 +282,7 @@ public class PetController {
@Nullable String additionalMetadata,
@Nullable CompletedFileUpload _file
) {
// TODO implement uploadFile() body;
Mono<ModelApiResponse> result = Mono.empty();
return result;
// TODO implement uploadFile();
return Mono.empty();
}
}

View File

@@ -27,7 +27,7 @@ import javax.validation.constraints.*;
import io.swagger.annotations.*;
@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen")
@Controller("${context-path}")
@Controller
public class StoreController {
/**
* Delete purchase order by ID
@@ -46,12 +46,11 @@ public class StoreController {
@ApiResponse(code = 404, message = "Order not found")})
@Delete(uri="/store/order/{orderId}")
@Produces(value = {})
public Mono<Object> deleteOrder(
public Mono<Void> deleteOrder(
@PathVariable(value="orderId") @NotNull String orderId
) {
// TODO implement deleteOrder() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement deleteOrder();
return Mono.empty();
}
/**
@@ -75,9 +74,8 @@ public class StoreController {
@Get(uri="/store/inventory")
@Produces(value = {"application/json"})
public Mono<Map<String, Integer>> getInventory() {
// TODO implement getInventory() body;
Mono<Map<String, Integer>> result = Mono.empty();
return result;
// TODO implement getInventory();
return Mono.empty();
}
/**
@@ -103,9 +101,8 @@ public class StoreController {
public Mono<Order> getOrderById(
@PathVariable(value="orderId") @NotNull @Min(1L) @Max(5L) Long orderId
) {
// TODO implement getOrderById() body;
Mono<Order> result = Mono.empty();
return result;
// TODO implement getOrderById();
return Mono.empty();
}
/**
@@ -131,8 +128,7 @@ public class StoreController {
public Mono<Order> placeOrder(
@Body @NotNull @Valid Order order
) {
// TODO implement placeOrder() body;
Mono<Order> result = Mono.empty();
return result;
// TODO implement placeOrder();
return Mono.empty();
}
}

View File

@@ -28,7 +28,7 @@ import javax.validation.constraints.*;
import io.swagger.annotations.*;
@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen")
@Controller("${context-path}")
@Controller
public class UserController {
/**
* Create user
@@ -49,12 +49,11 @@ public class UserController {
@Post(uri="/user")
@Produces(value = {})
@Consumes(value = {"application/json"})
public Mono<Object> createUser(
public Mono<Void> createUser(
@Body @NotNull @Valid User user
) {
// TODO implement createUser() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement createUser();
return Mono.empty();
}
/**
@@ -76,12 +75,11 @@ public class UserController {
@Post(uri="/user/createWithArray")
@Produces(value = {})
@Consumes(value = {"application/json"})
public Mono<Object> createUsersWithArrayInput(
public Mono<Void> createUsersWithArrayInput(
@Body @NotNull List<User> user
) {
// TODO implement createUsersWithArrayInput() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement createUsersWithArrayInput();
return Mono.empty();
}
/**
@@ -103,12 +101,11 @@ public class UserController {
@Post(uri="/user/createWithList")
@Produces(value = {})
@Consumes(value = {"application/json"})
public Mono<Object> createUsersWithListInput(
public Mono<Void> createUsersWithListInput(
@Body @NotNull List<User> user
) {
// TODO implement createUsersWithListInput() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement createUsersWithListInput();
return Mono.empty();
}
/**
@@ -130,12 +127,11 @@ public class UserController {
@ApiResponse(code = 404, message = "User not found")})
@Delete(uri="/user/{username}")
@Produces(value = {})
public Mono<Object> deleteUser(
public Mono<Void> deleteUser(
@PathVariable(value="username") @NotNull String username
) {
// TODO implement deleteUser() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement deleteUser();
return Mono.empty();
}
/**
@@ -161,9 +157,8 @@ public class UserController {
public Mono<User> getUserByName(
@PathVariable(value="username") @NotNull String username
) {
// TODO implement getUserByName() body;
Mono<User> result = Mono.empty();
return result;
// TODO implement getUserByName();
return Mono.empty();
}
/**
@@ -190,9 +185,8 @@ public class UserController {
@QueryValue(value="username") @NotNull @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") String username,
@QueryValue(value="password") @NotNull String password
) {
// TODO implement loginUser() body;
Mono<String> result = Mono.empty();
return result;
// TODO implement loginUser();
return Mono.empty();
}
/**
@@ -212,10 +206,9 @@ public class UserController {
@ApiResponse(code = 0, message = "successful operation")})
@Get(uri="/user/logout")
@Produces(value = {})
public Mono<Object> logoutUser() {
// TODO implement logoutUser() body;
Mono<Object> result = Mono.empty();
return result;
public Mono<Void> logoutUser() {
// TODO implement logoutUser();
return Mono.empty();
}
/**
@@ -239,12 +232,11 @@ public class UserController {
@Put(uri="/user/{username}")
@Produces(value = {})
@Consumes(value = {"application/json"})
public Mono<Object> updateUser(
public Mono<Void> updateUser(
@PathVariable(value="username") @NotNull String username,
@Body @NotNull @Valid User user
) {
// TODO implement updateUser() body;
Mono<Object> result = Mono.empty();
return result;
// TODO implement updateUser();
return Mono.empty();
}
}

View File

@@ -1,10 +1,10 @@
context-path: "/v2/"
micronaut:
application:
name: petstore-micronaut-server
server:
port: 8080
context-path: "/v2"
security:
# authentication: bearer | cookie | session | idtoken