Add support for Micronaut Client (#10063)

* Create initial version of openapi micronaut generator

* Update validation, authorization, query parameters and time format

* Move micronaut to its own generator

* Add micronaut documentation

* Refactor and add tests to JavaMicronautClientGenerator

* Refactor model mustache for micronaut client

* Refactor model enum and pojo mustache files for micronaut client

* Move micronaut client generation to micronaut 3.0.0-M5 version

* Generate samples for micronaut client

* Add hidden files of generated samples for micronaut client

* Add and configure micronaut tests as maven profile

* Add option to choose between junit and spock for micronaut client generator

* Add tests for micronaut 'build' and 'test' options; regenerate micronaut samples
This commit is contained in:
Andriy Dmytruk 2021-08-15 16:36:45 +02:00 committed by GitHub
parent 2210c9f016
commit 09aa7bfd0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
240 changed files with 19920 additions and 0 deletions

View File

@ -0,0 +1,9 @@
generatorName: micronaut-client
outputDir: samples/client/petstore/java-micronaut-client/
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
additionalProperties:
artifactId: petstore-micronaut
hideGenerationTimestamp: "true"
configureAuth: "false"
build: "all"
test: "spock"

View File

@ -0,0 +1,297 @@
---
title: Config Options for micronaut-client
sidebar_label: micronaut-client
---
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations)| |null|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|apiPackage|package for generated api classes| |org.openapitools.api|
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-micronaut|
|artifactUrl|artifact URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|build|Specify for which build tool to generate files|<dl><dt>**gradle**</dt><dd>Gradle configuration is generated for the project</dd><dt>**all**</dt><dd>Both Gradle and Maven configurations are generated</dd><dt>**maven**</dt><dd>Maven configuration is generated for the project</dd></dl>|all|
|configPackage|Configuration package for generated code| |org.openapitools.configuration|
|configureAuth|Configure all the authorization methods as specified in the file| |false|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|groupId|groupId in generated pom.xml| |org.openapitools|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|ignoreAnyOfInEnum|Ignore anyOf keyword in enum| |false|
|invokerPackage|root package for generated code| |org.openapitools|
|java8|Use Java8 classes instead of third party equivalents. Starting in 5.x, JDK8 is the default and the support for JDK7, JDK6 has been dropped|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd></dl>|true|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
|parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|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|
|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|
|scmUrl|SCM URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|serializableModel|boolean - toggle &quot;implements Serializable&quot; for generated models| |false|
|snapshotVersion|Uses a SNAPSHOT version.|<dl><dt>**true**</dt><dd>Use a SnapShot Version</dd><dt>**false**</dt><dd>Use a Release Version</dd></dl>|null|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src/main/java|
|test|Specify which test tool to generate files for|<dl><dt>**junit**</dt><dd>Use JUnit as test tool</dd><dt>**spock**</dt><dd>Use Spock as test tool</dd></dl>|junit|
|title|Client service name| |OpenAPI Micronaut Client|
|useBeanValidation|Use BeanValidation API annotations| |true|
|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|
## IMPORT MAPPING
| Type/Alias | Imports |
| ---------- | ------- |
|Array|java.util.List|
|ArrayList|java.util.ArrayList|
|BigDecimal|java.math.BigDecimal|
|Date|java.util.Date|
|DateTime|org.joda.time.*|
|File|java.io.File|
|HashMap|java.util.HashMap|
|LinkedHashSet|java.util.LinkedHashSet|
|List|java.util.*|
|LocalDate|org.joda.time.*|
|LocalDateTime|org.joda.time.*|
|LocalTime|org.joda.time.*|
|Map|java.util.Map|
|Set|java.util.*|
|Timestamp|java.sql.Timestamp|
|URI|java.net.URI|
|UUID|java.util.UUID|
## INSTANTIATION TYPES
| Type/Alias | Instantiated By |
| ---------- | --------------- |
|array|ArrayList|
|map|HashMap|
|set|LinkedHashSet|
## LANGUAGE PRIMITIVES
<ul class="column-ul">
<li>Boolean</li>
<li>Double</li>
<li>Float</li>
<li>Integer</li>
<li>Long</li>
<li>Object</li>
<li>String</li>
<li>boolean</li>
<li>byte[]</li>
</ul>
## RESERVED WORDS
<ul class="column-ul">
<li>abstract</li>
<li>apiclient</li>
<li>apiexception</li>
<li>apiresponse</li>
<li>application</li>
<li>assert</li>
<li>authorization</li>
<li>body</li>
<li>boolean</li>
<li>break</li>
<li>byte</li>
<li>case</li>
<li>catch</li>
<li>char</li>
<li>class</li>
<li>client</li>
<li>configuration</li>
<li>const</li>
<li>continue</li>
<li>cookie</li>
<li>default</li>
<li>do</li>
<li>double</li>
<li>else</li>
<li>enum</li>
<li>extends</li>
<li>final</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>format</li>
<li>goto</li>
<li>header</li>
<li>if</li>
<li>implements</li>
<li>import</li>
<li>instanceof</li>
<li>int</li>
<li>interface</li>
<li>localreturntype</li>
<li>localvaraccept</li>
<li>localvaraccepts</li>
<li>localvarauthnames</li>
<li>localvarcollectionqueryparams</li>
<li>localvarcontenttype</li>
<li>localvarcontenttypes</li>
<li>localvarcookieparams</li>
<li>localvarformparams</li>
<li>localvarheaderparams</li>
<li>localvarpath</li>
<li>localvarpostbody</li>
<li>localvarqueryparams</li>
<li>long</li>
<li>native</li>
<li>new</li>
<li>null</li>
<li>object</li>
<li>package</li>
<li>pathvariable</li>
<li>private</li>
<li>protected</li>
<li>public</li>
<li>queryparam</li>
<li>queryvalue</li>
<li>return</li>
<li>short</li>
<li>static</li>
<li>strictfp</li>
<li>stringutil</li>
<li>super</li>
<li>switch</li>
<li>synchronized</li>
<li>this</li>
<li>throw</li>
<li>throws</li>
<li>transient</li>
<li>try</li>
<li>void</li>
<li>volatile</li>
<li>while</li>
</ul>
## FEATURE SET
### Client Modification Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✓|ToolingExtension
|Authorizations|✗|ToolingExtension
|UserAgent|✗|ToolingExtension
|MockServer|✗|ToolingExtension
### Data Type Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Custom|✗|OAS2,OAS3
|Int32|✓|OAS2,OAS3
|Int64|✓|OAS2,OAS3
|Float|✓|OAS2,OAS3
|Double|✓|OAS2,OAS3
|Decimal|✓|ToolingExtension
|String|✓|OAS2,OAS3
|Byte|✓|OAS2,OAS3
|Binary|✓|OAS2,OAS3
|Boolean|✓|OAS2,OAS3
|Date|✓|OAS2,OAS3
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Array|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum|✓|OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|ArrayOfCollectionOfModel|✓|ToolingExtension
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|MapOfEnum|✓|ToolingExtension
|MapOfModel|✓|ToolingExtension
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|MapOfCollectionOfModel|✓|ToolingExtension
|MapOfCollectionOfEnum|✓|ToolingExtension
### Documentation Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Readme|✓|ToolingExtension
|Model|✓|ToolingExtension
|Api|✓|ToolingExtension
### Global Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Host|✓|OAS2,OAS3
|BasePath|✓|OAS2,OAS3
|Info|✓|OAS2,OAS3
|Schemes|✗|OAS2,OAS3
|PartialSchemes|✓|OAS2,OAS3
|Consumes|✓|OAS2
|Produces|✓|OAS2
|ExternalDocumentation|✓|OAS2,OAS3
|Examples|✓|OAS2,OAS3
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✗|OAS3
|ParameterStyling|✗|OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3
### Parameter Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Path|✓|OAS2,OAS3
|Query|✓|OAS2,OAS3
|Header|✓|OAS2,OAS3
|Body|✓|OAS2
|FormUnencoded|✓|OAS2
|FormMultipart|✓|OAS2
|Cookie|✓|OAS3
### Schema Support Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
### Security Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✓|OAS3
|BearerToken|✗|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✓|OAS2,OAS3
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3

View File

@ -0,0 +1,327 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.CodegenConstants.INVOKER_PACKAGE;
public class JavaMicronautClientCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
private final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class);
public static final String OPT_TITLE = "title";
public static final String OPT_CONFIG_PACKAGE = "configPackage";
public static final String OPT_CONFIGURE_AUTH = "configureAuth";
public static final String OPT_BUILD = "build";
public static final String OPT_BUILD_GRADLE = "gradle";
public static final String OPT_BUILD_MAVEN = "maven";
public static final String OPT_BUILD_ALL = "all";
public static final String OPT_TEST = "test";
public static final String OPT_TEST_JUNIT = "junit";
public static final String OPT_TEST_SPOCK = "spock";
public static final String NAME = "micronaut-client";
protected String title;
protected String configPackage;
protected boolean useBeanValidation;
protected boolean configureAuthorization;
protected String buildTool;
protected String testTool;
public JavaMicronautClientCodegen() {
super();
title = "OpenAPI Micronaut Client";
invokerPackage = "org.openapitools";
configPackage = "org.openapitools.configuration";
useBeanValidation = true;
configureAuthorization = false;
buildTool = OPT_BUILD_ALL;
testTool = OPT_TEST_JUNIT;
modifyFeatureSet(features -> features
.includeDocumentationFeatures(
DocumentationFeature.Readme
)
.securityFeatures(EnumSet.of(
SecurityFeature.ApiKey,
SecurityFeature.BasicAuth,
SecurityFeature.OAuth2_Implicit,
SecurityFeature.OAuth2_AuthorizationCode,
SecurityFeature.OAuth2_ClientCredentials,
SecurityFeature.OAuth2_Password,
SecurityFeature.OpenIDConnect
))
);
outputFolder = "generated-code/javaMicronaut";
embeddedTemplateDir = templateDir = "java-micronaut-client";
apiPackage = "org.openapitools.api";
modelPackage = "org.openapitools.model";
invokerPackage = "org.openapitools";
artifactId = "openapi-micronaut";
updateOption(INVOKER_PACKAGE, this.getInvokerPackage());
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
apiTestTemplateFiles.clear();
additionalProperties.put("jackson", "true");
additionalProperties.put("openbrace", "{");
additionalProperties.put("closebrace", "}");
cliOptions.add(new CliOption(OPT_TITLE, "Client service name").defaultValue(title));
cliOptions.add(new CliOption(OPT_CONFIG_PACKAGE, "Configuration package for generated code").defaultValue(configPackage));
cliOptions.add(CliOption.newBoolean(OPT_CONFIGURE_AUTH, "Configure all the authorization methods as specified in the file", configureAuthorization));
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations", useBeanValidation));
CliOption buildToolOption = new CliOption(OPT_BUILD, "Specify for which build tool to generate files").defaultValue(buildTool);
buildToolOption.setEnum(new HashMap<String, String>(){{
put(OPT_BUILD_GRADLE, "Gradle configuration is generated for the project");
put(OPT_BUILD_MAVEN, "Maven configuration is generated for the project");
put(OPT_BUILD_ALL, "Both Gradle and Maven configurations are generated");
}});
cliOptions.add(buildToolOption);
CliOption testToolOption = new CliOption(OPT_TEST, "Specify which test tool to generate files for").defaultValue(testTool);
testToolOption.setEnum(new HashMap<String, String>(){{
put(OPT_TEST_JUNIT, "Use JUnit as test tool");
put(OPT_TEST_SPOCK, "Use Spock as test tool");
}});
cliOptions.add(testToolOption);
// Remove the date library option
cliOptions.stream().filter(o -> o.getOpt().equals("dateLibrary")).findFirst()
.ifPresent(v -> cliOptions.remove(v));
// Add reserved words
String[] reservedWordsArray = new String[]{
"client", "format", "queryvalue", "queryparam", "pathvariable", "header", "cookie",
"authorization", "body", "application"
};
reservedWords.addAll(Arrays.asList(reservedWordsArray));
}
@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}
@Override
public String getName() {
return NAME;
}
@Override
public String getHelp() {
return "Generates a Java Micronaut Client.";
}
@Override
public void processOpts() {
super.processOpts();
// Get properties
if (additionalProperties.containsKey(OPT_TITLE)) {
this.title = (String) additionalProperties.get(OPT_TITLE);
}
if (additionalProperties.containsKey(OPT_CONFIG_PACKAGE)) {
configPackage = (String) additionalProperties.get(OPT_CONFIG_PACKAGE);
} else {
additionalProperties.put(OPT_CONFIG_PACKAGE, configPackage);
}
if (additionalProperties.containsKey(INVOKER_PACKAGE)) {
invokerPackage = (String) additionalProperties.get(INVOKER_PACKAGE);
} else {
additionalProperties.put(INVOKER_PACKAGE, invokerPackage);
}
// Get boolean properties
if (additionalProperties.containsKey(USE_BEANVALIDATION)) {
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
}
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
if (additionalProperties.containsKey(OPT_CONFIGURE_AUTH)) {
this.configureAuthorization = convertPropertyToBoolean(OPT_CONFIGURE_AUTH);
}
writePropertyBack(OPT_CONFIGURE_AUTH, configureAuthorization);
// Get enum properties
if (additionalProperties.containsKey(OPT_BUILD)) {
switch ((String) additionalProperties.get(OPT_BUILD)) {
case OPT_BUILD_GRADLE:
case OPT_BUILD_MAVEN:
case OPT_BUILD_ALL:
this.buildTool = (String) additionalProperties.get(OPT_BUILD);
break;
default:
throw new RuntimeException("Build tool \"" + additionalProperties.get(OPT_BUILD) + "\" is not supported or misspelled.");
}
}
additionalProperties.put(OPT_BUILD, buildTool);
if (additionalProperties.containsKey(OPT_TEST)) {
switch((String) additionalProperties.get(OPT_TEST)) {
case OPT_TEST_JUNIT:
case OPT_TEST_SPOCK:
this.testTool = (String) additionalProperties.get(OPT_TEST);
break;
default:
throw new RuntimeException("Test tool \"" + additionalProperties.get(OPT_TEST) + "\" is not supported or misspelled.");
}
}
additionalProperties.put(OPT_TEST, testTool);
if (testTool.equals(OPT_TEST_JUNIT)) {
additionalProperties.put("isTestJunit", true);
} else if (testTool.equals(OPT_TEST_SPOCK)) {
additionalProperties.put("isTestSpock", true);
}
final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/");
final String apiFolder = (sourceFolder + '/' + apiPackage).replace(".", "/");
// Add all the supporting files
String resourceFolder = projectFolder + "/resources";
supportingFiles.add(new SupportingFile("configuration/application.yml.mustache", resourceFolder, "application.yml").doNotOverwrite());
// Authorization files
if (configureAuthorization) {
final String authFolder = invokerFolder + "/auth";
supportingFiles.add(new SupportingFile("auth/Authorization.mustache", authFolder, "Authorization.java"));
supportingFiles.add(new SupportingFile("auth/AuthorizationBinder.mustache", authFolder, "AuthorizationBinder.java"));
supportingFiles.add(new SupportingFile("auth/Authorizations.mustache", authFolder, "Authorizations.java"));
supportingFiles.add(new SupportingFile("auth/AuthorizationFilter.mustache", authFolder, "AuthorizationFilter.java"));
final String authConfigurationFolder = authFolder + "/configuration";
supportingFiles.add(new SupportingFile("auth/configuration/ApiKeyAuthConfiguration.mustache", authConfigurationFolder, "ApiKeyAuthConfiguration.java"));
supportingFiles.add(new SupportingFile("auth/configuration/ConfigurableAuthorization.mustache", authConfigurationFolder, "ConfigurableAuthorization.java"));
supportingFiles.add(new SupportingFile("auth/configuration/HttpBasicAuthConfiguration.mustache", authConfigurationFolder, "HttpBasicAuthConfiguration.java"));
}
// Query files
final String queryFolder = invokerFolder + "/query";
supportingFiles.add(new SupportingFile("query/QueryParam.mustache", queryFolder, "QueryParam.java"));
supportingFiles.add(new SupportingFile("query/QueryParamBinder.mustache", queryFolder, "QueryParamBinder.java"));
if (buildTool.equals(OPT_BUILD_GRADLE) || buildTool.equals(OPT_BUILD_ALL)) {
// Gradle files
supportingFiles.add(new SupportingFile("configuration/gradle/build.gradle.mustache", "", "build.gradle").doNotOverwrite());
supportingFiles.add(new SupportingFile("configuration/gradle/settings.gradle.mustache", "", "settings.gradle").doNotOverwrite());
supportingFiles.add(new SupportingFile("configuration/gradle/gradle.properties.mustache", "", "gradle.properties").doNotOverwrite());
// Gradlew files
final String gradleWrapperFolder = "gradle/wrapper";
supportingFiles.add(new SupportingFile("configuration/gradlew/gradlew.mustache", "", "gradlew"));
supportingFiles.add(new SupportingFile("configuration/gradlew/gradlew.bat.mustache", "", "gradlew.bat"));
supportingFiles.add(new SupportingFile("configuration/gradlew/gradle-wrapper.properties.mustache", gradleWrapperFolder, "gradle-wrapper.properties"));
supportingFiles.add(new SupportingFile("configuration/gradlew/gradle-wrapper.jar", gradleWrapperFolder, "gradle-wrapper.jar"));
}
if (buildTool.equals(OPT_BUILD_MAVEN) || buildTool.equals(OPT_BUILD_ALL)) {
// Maven files
supportingFiles.add(new SupportingFile("configuration/pom.xml.mustache", "", "pom.xml").doNotOverwrite());
// Maven wrapper files
supportingFiles.add(new SupportingFile("configuration/mavenw/mvnw.mustache", "", "mvnw"));
supportingFiles.add(new SupportingFile("configuration/mavenw/mvnw.bat.mustache", "", "mvnw.bat"));
supportingFiles.add(new SupportingFile("configuration/mavenw/MavenWrapperDownloader.java.mustache", ".mvn/wrapper", "MavenWrapperDownloader.java"));
supportingFiles.add(new SupportingFile("configuration/mavenw/maven-wrapper.jar.mustache", ".mvn/wrapper", "maven-wrapper.jar"));
supportingFiles.add(new SupportingFile("configuration/mavenw/maven-wrapper.properties.mustache", ".mvn/wrapper", "maren-wrapper.properties"));
}
// Git files
supportingFiles.add(new SupportingFile("configuration/git/gitignore.mustache", "", ".gitignore").doNotOverwrite());
// Use the default java Date
typeMapping.put("date", "LocalDate");
typeMapping.put("DateTime", "LocalDateTime");
importMapping.put("LocalDate", "java.time.LocalDate");
importMapping.put("LocalDateTime", "java.time.LocalDateTime");
// Add documentation files
supportingFiles.add(new SupportingFile("doc/README.mustache", "", "README.md").doNotOverwrite());
supportingFiles.add(new SupportingFile("doc/auth.mustache", apiDocPath, "auth.md"));
modelDocTemplateFiles.put("doc/model_doc.mustache", ".md");
apiDocTemplateFiles.put("doc/api_doc.mustache", ".md");
modelDocTemplateFiles.remove("model_doc.mustache");
apiDocTemplateFiles.remove("api_doc.mustache");
// Add model files
modelTemplateFiles.remove("model.mustache");
modelTemplateFiles.put("model/model.mustache", ".java");
// Add test files
if (testTool.equals(OPT_TEST_JUNIT)) {
apiTestTemplateFiles.put("api_test.mustache", ".java");
modelTestTemplateFiles.put("model_test.mustache", ".java");
} else if (testTool.equals(OPT_TEST_SPOCK)) {
apiTestTemplateFiles.put("api_test.groovy.mustache", ".groovy");
modelTestTemplateFiles.put("model_test.groovy.mustache", ".groovy");
}
}
@Override
public String apiTestFileFolder() {
if (testTool.equals(OPT_TEST_SPOCK)) {
return getOutputDir() + "/src/test/groovy/" + getInvokerPackage().replaceAll("\\.", "/") + "/api";
}
return getOutputDir() + "/src/test/java/" + getInvokerPackage().replaceAll("\\.", "/") + "/api";
}
@Override
public String modelTestFileFolder() {
if (testTool.equals(OPT_TEST_SPOCK)) {
return getOutputDir() + "/src/test/groovy/" + getInvokerPackage().replaceAll("\\.", "/") + "/model";
}
return getOutputDir() + "/src/test/java/" + getInvokerPackage().replaceAll("\\.", "/") + "/model";
}
@Override
public String toApiTestFilename(String name) {
if (testTool.equals(OPT_TEST_SPOCK)) {
return toApiName(name) + "Spec";
}
return toApiName(name) + "Test";
}
@Override
public String toModelTestFilename(String name) {
if (testTool.equals(OPT_TEST_SPOCK)) {
return toModelName(name) + "Spec";
}
return toModelName(name) + "Test";
}
@Override
public void setUseBeanValidation(boolean useBeanValidation) {
this.useBeanValidation = useBeanValidation;
}
@Override
public String toApiVarName(String name) {
String apiVarName = super.toApiVarName(name);
if (reservedWords.contains(apiVarName)) {
apiVarName = escapeReservedWord(apiVarName);
}
return apiVarName;
}
public boolean isUseBeanValidation() {
return useBeanValidation;
}
public boolean isConfigureAuthorization() {
return configureAuthorization;
}
}

View File

@ -55,6 +55,7 @@ org.openapitools.codegen.languages.HaskellServantCodegen
org.openapitools.codegen.languages.JavaClientCodegen org.openapitools.codegen.languages.JavaClientCodegen
org.openapitools.codegen.languages.JavaCXFClientCodegen org.openapitools.codegen.languages.JavaCXFClientCodegen
org.openapitools.codegen.languages.JavaInflectorServerCodegen org.openapitools.codegen.languages.JavaInflectorServerCodegen
org.openapitools.codegen.languages.JavaMicronautClientCodegen
org.openapitools.codegen.languages.JavaMSF4JServerCodegen org.openapitools.codegen.languages.JavaMSF4JServerCodegen
org.openapitools.codegen.languages.JavaPKMSTServerCodegen org.openapitools.codegen.languages.JavaPKMSTServerCodegen
org.openapitools.codegen.languages.JavaPlayFrameworkCodegen org.openapitools.codegen.languages.JavaPlayFrameworkCodegen

View File

@ -0,0 +1,70 @@
{{>licenseInfo}}
package {{package}};
import io.micronaut.http.annotation.*;
import io.micronaut.core.annotation.*;
import io.micronaut.http.client.annotation.Client;
{{#configureAuth}}
import {{invokerPackage}}.auth.Authorization;
{{/configureAuth}}
import {{invokerPackage}}.query.QueryParam;
import io.micronaut.core.convert.format.Format;
import reactor.core.publisher.Mono;
{{#imports}}import {{import}};
{{/imports}}
import javax.annotation.Generated;
{{^fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}{{#useBeanValidation}}
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/useBeanValidation}}
{{>generatedAnnotation}}
@Client("${base-path}")
public interface {{classname}} {
{{#operations}}{{#operation}}
/**
{{#summary}}
* {{summary}}
{{/summary}}
{{#notes}}
* {{notes}}
{{/notes}}
{{^summary}}
{{^notes}}
* {{nickname}}
{{/notes}}
{{/summary}}
*
{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
{{#returnType}}
* @return {{returnType}}
{{/returnType}}
{{#externalDocs}}
* {{description}}
* @see <a href="{{url}}">{{summary}} Documentation</a>
{{/externalDocs}}
*/
@{{#lambda.pascalcase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.pascalcase}}(uri="{{{path}}}")
{{#vendorExtensions.x-contentType}}
@Produces(value={"{{vendorExtensions.x-contentType}}"})
{{/vendorExtensions.x-contentType}}
@Consumes(value={"{{vendorExtensions.x-accepts}}"})
{{!auth methods}}
{{#configureAuth}}
{{#authMethods}}
@Authorization(name="{{{name}}}"{{!scopes}}{{#isOAuth}}, scopes={{=< >=}}{<={{ }}=>{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}{{=< >=}}}<={{ }}=>{{/isOAuth}})
{{/authMethods}}
{{/configureAuth}}
{{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Object>{{/returnType}} {{nickname}}({{^allParams}});{{/allParams}}{{#allParams}}
{{>params/queryParams}}{{>params/pathParams}}{{>params/headerParams}}{{>params/bodyParams}}{{>params/formParams}}{{>params/cookieParams}}{{^-last}}, {{/-last}}{{#-last}}
);{{/-last}}{{/allParams}}
{{/operation}}
{{/operations}}
}

View File

@ -0,0 +1,48 @@
package {{package}}
{{#imports}}import {{import}}
{{/imports}}
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import spock.lang.Specification
import jakarta.inject.Inject
import reactor.core.publisher.Mono
{{^fullJavaUtil}}
import java.util.ArrayList
import java.util.HashMap
import java.util.List
import java.util.Map
{{/fullJavaUtil}}
/**
* API tests for {{classname}}
*/
@MicronautTest
class {{classname}}Spec extends Specification {
@Inject
{{classname}} api
{{#operations}}{{#operation}}
/**
* {{summary}}
{{#notes}}
*
* {{notes}}
{{/notes}}
*/
void '{{operationId}}() test'() {
given:
{{#allParams}}
{{{dataType}}} {{paramName}} = null
{{/allParams}}
// {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).block()
// {{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Void>{{/returnType}} asyncResponse = api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
expect:
true
// TODO: test validations
}
{{/operation}}{{/operations}}
}

View File

@ -0,0 +1,47 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import jakarta.inject.Inject;
import reactor.core.publisher.Mono;
{{^fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}
/**
* API tests for {{classname}}
*/
@MicronautTest
public class {{classname}}Test {
@Inject
{{classname}} api;
{{#operations}}{{#operation}}
/**
* {{summary}}
{{#notes}}
*
* {{notes}}
{{/notes}}
*/
@Test
public void {{operationId}}Test() {
{{#allParams}}
{{{dataType}}} {{paramName}} = null;
{{/allParams}}
// {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).block();
// {{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Void>{{/returnType}} asyncResponse = api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
// TODO: test validations
}
{{/operation}}{{/operations}}
}

View File

@ -0,0 +1,40 @@
{{>licenseInfo}}
package {{invokerPackage}}.auth;
import io.micronaut.context.annotation.AliasFor;
import io.micronaut.core.bind.annotation.Bindable;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import javax.annotation.Generated;
{{>generatedAnnotation}}
@Documented
@Retention(RUNTIME)
@Target(METHOD)
@Bindable
@Repeatable(Authorizations.class)
public @interface Authorization {
/**
* The name of the authorization
*/
@AliasFor(annotation=Bindable.class, member="value")
String value() default "";
/**
* The name of the authorization
*/
@AliasFor(annotation=Bindable.class, member="value")
String name() default "";
/**
* The scopes for the oauth authorization
*/
String[] scopes() default {};
}

View File

@ -0,0 +1,72 @@
{{>licenseInfo}}
package {{invokerPackage}}.auth;
import io.micronaut.aop.MethodInvocationContext;
import io.micronaut.core.annotation.AnnotationValue;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.util.CollectionUtils;
import io.micronaut.core.util.StringUtils;
import io.micronaut.http.MutableHttpRequest;
import io.micronaut.http.client.bind.AnnotatedClientRequestBinder;
import io.micronaut.http.client.bind.ClientRequestUriContext;
import jakarta.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
{{>generatedAnnotation}}
@Singleton
public class AuthorizationBinder implements AnnotatedClientRequestBinder<Authorization> {
public static final CharSequence AUTHORIZATION_NAMES = "micronaut.security.AUTHORIZATION_NAMES";
@NonNull
@Override
public Class<Authorization> getAnnotationType() {
return Authorization.class;
}
@Override
public void bind(@NonNull MethodInvocationContext<Object, Object> context,
@NonNull ClientRequestUriContext uriContext,
@NonNull MutableHttpRequest<?> request
) {
List<AnnotationValue<Authorization>> annotations = context.getAnnotationMetadata()
.getAnnotationValuesByType(Authorization.class);
if (CollectionUtils.isNotEmpty(annotations)) {
List<String> authorizationNames = new ArrayList<>();
for (AnnotationValue<Authorization> annotation: annotations) {
annotation.get("name", String.class)
.filter(StringUtils::isNotEmpty)
.ifPresent(v -> authorizationNames.add(configurationName(v)));
}
request.setAttribute(AUTHORIZATION_NAMES, authorizationNames);
}
}
private String configurationName(String name) {
StringBuilder result = new StringBuilder();
boolean wasCapital = false;
for (int i = 0; i < name.length(); ++i) {
char c = name.charAt(i);
if (c == '_') {
result.append('-');
wasCapital = true;
} else if (Character.isUpperCase(c)) {
if (wasCapital) {
result.append(Character.toLowerCase(c));
} else {
result.append('-');
result.append(Character.toLowerCase(c));
}
wasCapital = true;
} else {
result.append(c);
}
}
return result.toString();
}
}

View File

@ -0,0 +1,157 @@
{{>licenseInfo}}
package {{invokerPackage}}.auth;
import io.micronaut.context.BeanContext;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.util.CollectionUtils;
import io.micronaut.core.util.StringUtils;
import io.micronaut.core.util.Toggleable;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MutableHttpRequest;
import io.micronaut.http.annotation.Filter;
import io.micronaut.http.filter.ClientFilterChain;
import io.micronaut.http.filter.HttpClientFilter;
import io.micronaut.inject.qualifiers.Qualifiers;
import io.micronaut.security.oauth2.client.clientcredentials.ClientCredentialsClient;
import io.micronaut.security.oauth2.client.clientcredentials.ClientCredentialsConfiguration;
import io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsHttpClientFilter;
import io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsTokenPropagator;
import io.micronaut.security.oauth2.configuration.OauthClientConfiguration;
import io.micronaut.security.oauth2.endpoint.token.response.TokenResponse;
import org.openapitools.auth.configuration.ConfigurableAuthorization;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Generated;
{{>generatedAnnotation}}
@Filter(Filter.MATCH_ALL_PATTERN)
public class AuthorizationFilter implements HttpClientFilter {
private static final Logger LOG = LoggerFactory.getLogger(ClientCredentialsHttpClientFilter.class);
private final BeanContext beanContext;
private final Map<String, OauthClientConfiguration> clientConfigurationByName;
ClientCredentialsTokenPropagator defaultTokenPropagator;
private final Map<String, ClientCredentialsTokenPropagator> tokenPropagatorByName;
private final Map<String, ClientCredentialsClient> clientCredentialsClientByName;
public final Map<String, ConfigurableAuthorization> authorizationsByName;
public AuthorizationFilter(
BeanContext beanContext,
Stream<OauthClientConfiguration> clientConfigurations,
ClientCredentialsTokenPropagator defaultTokenPropagator,
Stream<ConfigurableAuthorization> configurableAuthorizations
) {
this.beanContext = beanContext;
this.clientConfigurationByName = clientConfigurations
.filter(Toggleable::isEnabled)
.collect(Collectors.toMap(OauthClientConfiguration::getName, v -> v));
this.defaultTokenPropagator = defaultTokenPropagator;
this.tokenPropagatorByName = new HashMap<>();
this.clientCredentialsClientByName = new HashMap<>();
this.authorizationsByName = configurableAuthorizations
.collect(Collectors.toMap(ConfigurableAuthorization::getName, v -> v));
}
@Override
public Publisher<? extends HttpResponse<?>> doFilter(
@NonNull MutableHttpRequest<?> request,
@NonNull ClientFilterChain chain
) {
List<?> names = request.getAttribute(AuthorizationBinder.AUTHORIZATION_NAMES, List.class).orElse(null);
if (CollectionUtils.isNotEmpty(names)) {
List<Publisher<HttpRequest>> authorizers = new ArrayList<>(names.size());
for (Object nameObject: names) {
if (!(nameObject instanceof String)) {
continue;
}
String name = (String) nameObject;
// Check if other authorizations have the key
if (authorizationsByName.containsKey(name)) {
ConfigurableAuthorization authorizer = authorizationsByName.get(name);
authorizers.add(Mono.fromCallable(() -> {
authorizer.applyAuthorization(request);
return request;
}));
continue;
}
// Perform OAuth authorization
OauthClientConfiguration clientConfiguration = clientConfigurationByName.get(name);
if (clientConfiguration == null) {
continue;
}
ClientCredentialsClient clientCredentialsClient = getClientCredentialsClient(name);
if (clientCredentialsClient == null) {
if (LOG.isTraceEnabled()) {
LOG.trace("Could not retrieve client credentials client for OAuth 2.0 client {}", name);
}
continue;
}
ClientCredentialsTokenPropagator tokenHandler = getTokenPropagator(name);
Flux<HttpRequest> authorizer = Flux.from(clientCredentialsClient
.requestToken(getScope(clientConfiguration)))
.map(TokenResponse::getAccessToken)
.map(accessToken -> {
if (StringUtils.isNotEmpty(accessToken)) {
tokenHandler.writeToken(request, accessToken);
}
return request;
});
authorizers.add(authorizer);
}
return Flux.concat(authorizers)
.switchMap(v -> chain.proceed(request));
}
return chain.proceed(request);
}
protected ClientCredentialsTokenPropagator getTokenPropagator(String name) {
ClientCredentialsTokenPropagator tokenPropagator = tokenPropagatorByName.get(name);
if (tokenPropagator == null) {
tokenPropagator = beanContext.findBean(ClientCredentialsTokenPropagator.class, Qualifiers.byName(name))
.orElse(defaultTokenPropagator);
if (tokenPropagator != null) {
tokenPropagatorByName.put(name, tokenPropagator);
}
}
return tokenPropagator;
}
protected ClientCredentialsClient getClientCredentialsClient(String name) {
ClientCredentialsClient client = clientCredentialsClientByName.get(name);
if (client == null) {
client = beanContext.findBean(ClientCredentialsClient.class, Qualifiers.byName(name)).orElse(null);
if (client != null) {
clientCredentialsClientByName.put(name, client);
}
}
return client;
}
@Nullable
protected String getScope(@NonNull OauthClientConfiguration oauthClient) {
return oauthClient.getClientCredentials().flatMap(ClientCredentialsConfiguration::getScope).orElse(null);
}
}

View File

@ -0,0 +1,21 @@
{{>licenseInfo}}
package {{invokerPackage}}.auth;
import io.micronaut.core.bind.annotation.Bindable;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import javax.annotation.Generated;
{{>generatedAnnotation}}
@Documented
@Retention(RUNTIME)
@Target(METHOD)
@Bindable
public @interface Authorizations {
Authorization[] value();
}

View File

@ -0,0 +1,79 @@
{{>licenseInfo}}
package {{invokerPackage}}.auth.configuration;
import io.micronaut.context.annotation.ConfigurationInject;
import io.micronaut.context.annotation.EachProperty;
import io.micronaut.context.annotation.Parameter;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.http.MutableHttpRequest;
import io.micronaut.http.cookie.Cookie;
import javax.annotation.Generated;
{{>generatedAnnotation}}
@EachProperty("security.api-key-auth")
public class ApiKeyAuthConfiguration implements ConfigurableAuthorization {
private final String name;
private AuthKeyLocation location;
private String paramName;
private String apiKey;
@ConfigurationInject
public ApiKeyAuthConfiguration(
@Parameter String name,
@NonNull AuthKeyLocation location,
@NonNull String paramName,
@NonNull String apiKey
) {
this.name = name;
this.location = location;
this.paramName = paramName;
this.apiKey = apiKey;
}
@Override
public void applyAuthorization(@NonNull MutableHttpRequest<?> request) {
if (this.location == AuthKeyLocation.HEADER) {
request.header(this.paramName, this.apiKey);
} else if (this.location == AuthKeyLocation.QUERY) {
request.getParameters().add(this.paramName, this.apiKey);
} else if (this.location == AuthKeyLocation.COOKIE) {
request.cookie(Cookie.of(this.paramName, this.apiKey));
}
}
@Override
public String getName() {
return name;
}
public AuthKeyLocation getLocation() {
return location;
}
public String getParamName() {
return paramName;
}
public String getApiKey() {
return apiKey;
}
public void setLocation(AuthKeyLocation location) {
this.location = location;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public enum AuthKeyLocation {
HEADER,
QUERY,
COOKIE;
}
}

View File

@ -0,0 +1,14 @@
{{>licenseInfo}}
package {{invokerPackage}}.auth.configuration;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.http.MutableHttpRequest;
import javax.annotation.Generated;
{{>generatedAnnotation}}
public interface ConfigurableAuthorization {
String getName();
void applyAuthorization(@NonNull MutableHttpRequest<?> request);
}

View File

@ -0,0 +1,55 @@
{{>licenseInfo}}
package {{invokerPackage}}.auth.configuration;
import io.micronaut.context.annotation.ConfigurationInject;
import io.micronaut.context.annotation.EachProperty;
import io.micronaut.context.annotation.Parameter;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.http.MutableHttpRequest;
import javax.annotation.Generated;
{{>generatedAnnotation}}
@EachProperty("security.basic-auth")
public class HttpBasicAuthConfiguration implements ConfigurableAuthorization {
private final String name;
private String username;
private String password;
@ConfigurationInject
public HttpBasicAuthConfiguration(
@Parameter String name,
@NonNull String username,
@NonNull String password
) {
this.name = name;
this.username = username;
this.password = password;
}
@Override
public void applyAuthorization(@NonNull MutableHttpRequest<?> request) {
request.basicAuth(username, password);
}
@Override
public String getName() {
return this.name;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@ -0,0 +1,9 @@
package {{invokerPackage}};
import io.micronaut.runtime.Micronaut;
public class Application {
public static void main(String[] args) {
Micronaut.run(Application.class, args);
}
}

View File

@ -0,0 +1,62 @@
base-path: "{{{basePath}}}"
context-path: "{{{contextPath}}}"
micronaut:
application:
name: {{artifactId}}
{{!
configure authorization from the parameters
}}{{#configureAuth}}security:
oauth2:
clients:{{#oauthMethods}}
{{{name}}}:
grant-type: {{#isCode}}authorization_code{{/isCode}}{{#isImplicit}}implicit{{/isImplicit}}{{#isPassword}}password{{/isPassword}}{{#isApplication}}client_credentials{{/isApplication}}
scopes: [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]{{!authorization url}}{{#authorizationUrl}}
authorization:
url: "{{{authorizationUrl}}}"{{/authorizationUrl}}{{!token url}}{{#tokenUrl}}
token:
auth-method: client_secret_basic
url: "{{{tokenUrl}}}"{{/tokenUrl}}{{!refreshUrl is not used}}
# TODO Fill in the parameters for {{{name}}} authorization if needed
# client-id:
# client-secret:{{/oauthMethods}}{{/configureAuth}}{{!
do not configure authorization, but leave hints for user
}}{{^configureAuth}}# TODO configure security features
security:
oauth2:
clients:
# An example of how oauth client is filled
# name:
# grant-type: authorization_code | client_credentials
# scopes: []
# token:
# auth-method: client_secret_basic
# url: "https://"
# client-id:
# client-secret
# An example of how to apply other authorization methods
# authentication: bearer | cookie | session{{/configureAuth}}
{{#configureAuth}}security:
{{!api key authorization}}api-key-auth:{{#authMethods}}{{#isApiKey}}
{{{name}}}:
location: {{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}{{#isKeyInCookie}}cookie{{/isKeyInCookie}}
param-name: "{{{keyParamName}}}"
# TODO fill in api key for {{{name}}} authorization
api-key:
{{/isApiKey}}{{/authMethods}}
{{!basic authorization}}basic-auth:{{#authMethods}}{{#isBasic}}
{{{name}}}:
# TODO fill in credentials for {{{name}}} authorization
username:
password:
{{/isBasic}}{{/authMethods}}{{/configureAuth}}
jackson:
serialization:
writeEnumsUsingToString: true
writeDatesAsTimestamps: false
deserialization:
readEnumsUsingToString: true
failOnUnknownProperties: false
failOnInvalidSubtype: false

View File

@ -0,0 +1,58 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
git_host="{{{gitHost}}}"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="{{{gitRepoId}}}"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="{{{releaseNote}}}"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1,21 @@
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# exclude jar for gradle wrapper
!gradle/wrapper/*.jar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# build files
**/target
target
.gradle
build

View File

@ -0,0 +1,51 @@
plugins {
{{#isTestSpock}}
id("groovy")
{{/isTestSpock}}
id("com.github.johnrengelman.shadow") version "7.0.0"
id("io.micronaut.application") version "2.0.3"
}
version = "{{artifactVersion}}"
group = "{{invokerPackage}}"
repositories {
mavenCentral()
}
micronaut {
runtime("netty")
{{#isTestSpock}}
testRuntime("spock2")
{{/isTestSpock}}
{{#isTestJunit}}
testRuntime("junit5")
{{/isTestJunit}}
processing {
incremental(true)
annotations("{{invokerPackage}}.*")
}
}
dependencies {
annotationProcessor("io.micronaut:micronaut-http-validation")
annotationProcessor("io.micronaut.security:micronaut-security-annotations")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut:micronaut-validation")
implementation("io.micronaut.security:micronaut-security")
implementation("io.micronaut.security:micronaut-security-oauth2")
implementation("io.micronaut.reactor:micronaut-reactor")
implementation("io.swagger:swagger-annotations:1.5.9")
runtimeOnly("ch.qos.logback:logback-classic")
}
// TODO Set the main class
application {
mainClass.set("{{invokerPackage}}.Application")
}
java {
sourceCompatibility = JavaVersion.toVersion("1.8")
targetCompatibility = JavaVersion.toVersion("1.8")
}

View File

@ -0,0 +1 @@
rootProject.name = "{{artifactId}}"

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip

View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,124 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

View File

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

View File

@ -0,0 +1,182 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

View File

@ -0,0 +1,310 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

View File

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<version>{{artifactVersion}}</version>
<packaging>${packaging}</packaging>
<parent>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-parent</artifactId>
<version>3.0.0-M5</version>
</parent>
<properties>
<packaging>jar</packaging>
<jdk.version>1.8</jdk.version>
<!-- If you are building with JDK 9 or higher, you can uncomment the lines below to set the release version -->
<!-- <release.version>8</release.version> -->
<micronaut.version>3.0.0-M5</micronaut.version>
<exec.mainClass>{{groupId}}.Application</exec.mainClass>
<micronaut.runtime>netty</micronaut.runtime>
<swagger-annotations-version>1.5.21</swagger-annotations-version>
</properties>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<scope>compile</scope>
</dependency>
{{#isTestSpock}}
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-groovy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.micronaut.test</groupId>
<artifactId>micronaut-test-spock</artifactId>
<scope>test</scope>
</dependency>
{{/isTestSpock}}
{{#isTestJunit}}
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.micronaut.test</groupId>
<artifactId>micronaut-test-junit5</artifactId>
<scope>test</scope>
</dependency>
{{/isTestJunit}}
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-client</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-server-netty</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-runtime</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut.reactor</groupId>
<artifactId>micronaut-reactor</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut.security</groupId>
<artifactId>micronaut-security</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut.security</groupId>
<artifactId>micronaut-security-oauth2</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.micronaut.build</groupId>
<artifactId>micronaut-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- Uncomment to enable incremental compilation -->
<!-- <useIncrementalCompilation>false</useIncrementalCompilation> -->
<annotationProcessorPaths combine.children="append">
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-validation</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.security</groupId>
<artifactId>micronaut-security-annotations</artifactId>
<version>${micronaut.security.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amicronaut.processing.group={{groupId}}</arg>
<arg>-Amicronaut.processing.module={{artifactId}}</arg>
</compilerArgs>
</configuration>
</plugin>
{{#isTestSpock}}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Spec.*</include>
<include>**/*Test.*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>removeStubs</goal>
<goal>addTestSources</goal>
<goal>generateTestStubs</goal>
<goal>compileTests</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
</plugin>
{{/isTestSpock}}
</plugins>
</build>
</project>

View File

@ -0,0 +1,39 @@
# {{artifactId}}
This is a generated client based on [Micronaut](https://micronaut.io/) framework.
## Configuration
A Micronaut's application can be created by defyning a main class and running:
```java
import io.micronaut.runtime.Micronaut;
import io.micronaut.context.ApplicationContext;
public class Application {
public static void main(String[] args) {
ApplicationContext context = Micronaut.run(Application.class);
}
}
```
More detailed description can be found in the [Micronaut Guide](https://docs.micronaut.io/latest/guide/#ideSetup).
All the properties can be changed in the [application.yml][src/main/resources/application.yml] file or when creating micronaut application as described in [Configuration section of guide](https://docs.micronaut.io/latest/guide/#config).
## Api Guides
Description on how to create Apis is given inside individual api guides:
{{#apiInfo}}{{#apis}}* [{{classFilename}}]({{apiDocPath}}/{{classFilename}}.md)
{{/apis}}{{/apiInfo}}
## Auth methods
Details on auth methods can be found in the [auth.md](doc/auth.md).
## Author
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
{{/hasMore}}{{/apis}}{{/apiInfo}}

View File

@ -0,0 +1,68 @@
# {{classname}}{{#description}}
{{description}}{{/description}}
All URIs are relative to *{{basePath}}*
Method | HTTP request | Description
------------- | ------------- | -------------
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}
## Creating {{classname}}
To initiate an instance of `{{classname}}`, you can use micronaut's `ApplicationContext`:
```java
/* imports
import io.micronaut.runtime.Micronaut;
import io.micronaut.context.ApplicationContext;
import {{package}}.{{classname}};
*/
ApplicationContext context = Micronaut.run(/* ... */);
PetApi apiInstance = context.getBean({{classname}}.class);
```
Or the `@Inject` annotation:
```java
@Singleton
class MyClass {
@Inject
{{classname}} {{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}};
/* ... use the injected variable */
}
```
Note that the class needs to be annotated with one of Micronaut's [scope annotations](https://docs.micronaut.io/latest/guide/#scopes) like `Singleton` in order to be processed.
More information can be found inside [Inversion of Control guide section](https://docs.micronaut.io/latest/guide/#ioc).
{{#operations}}
{{#operation}}
<a name="{{operationId}}"></a>
# **{{operationId}}**
```java
{{#returnType}}Mono<{{{returnType}}}>{{/returnType}}{{^returnType}}Mono<Void>{{/returnType}} {{classname}}.{{nickname}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
```
{{summary}}{{#notes}}
{{notes}}{{/notes}}
{{#allParams}}{{#-last}}### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}`{{dataType}}`{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}`{{dataType}}`{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional parameter]{{/required}}{{#defaultValue}} [default to `{{defaultValue}}`]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}`{{{.}}}`{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}}
{{/allParams}}{{/-last}}{{/allParams}}
{{#returnType}}### Return type
{{#returnTypeIsPrimitive}}`{{returnType}}`{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}
{{#authMethods}}{{#-last}}### Authorization{{#authMethods}}
* **[{{name}}](auth.md#{{name}})**{{#scopes}}{{#-last}}, scopes: {{#scopes}}`{{{scope}}}`{{^-last}}, {{/-last}}{{/scopes}}{{/-last}}{{/scopes}}{{/authMethods}}{{/-last}}{{/authMethods}}
### HTTP request headers
- **Content-Type**: {{#consumes}}`{{{mediaType}}}`{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}`{{{mediaType}}}`{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
{{/operation}}
{{/operations}}

View File

@ -0,0 +1,25 @@
# Authorization methods
{{#authMethods}}
<a name="name"></a>
# {{name}}
{{!
basic auth
}}{{#isBasic}}Authorization method is of **basic auth**.
{{#configureAuth}}The configuration for it can be found in [application.yml](src/main/resources/application.yml) at `security.basic-auth.{{name}}`. `username` and `password` need to be filled for it to work correctly.{{/configureAuth}}{{^configureAuth}}It can be configured in the [application.yml](src/main/resources/application.yml) using Micronaut security features.{{/configureAuth}}
{{/isBasic}}{{!
api key
}}{{#isApiKey}}Authorization method is of **api key type**. The parameter `{{{keyParamName}}}` is located in `{{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}{{#isKeyInCookie}}cookie{{/isKeyInCookie}}`.
{{#configureAuth}}The configuration for it can be found in [application.yml](src/main/resources/application.yml) at `security.api-key-auth.{{name}}`. The `api-key` parameter needs to be filled in order for it to work correctly.{{/configureAuth}}{{^configureAuth}}It can be configured in the [application.yml](src/main/resources/application.yml) using Micronaut security features.{{/configureAuth}}
{{/isApiKey}}{{!
oauth
}}{{#isOAuth}}Authorization method is **OAuth2** with `{{flow}}` flow.
{{!scopes}}{{#scopes}}{{#-last}}The scopes are: {{#scopes}}
* `{{{scope}}}`{{/scopes}}{{/-last}}{{/scopes}}
{{#configureAuth}}The configuration for it can be found in [application.yml](src/main/resources/application.yml) at `micronaut.security.oauth2.clients.{{name}}`. Some parameters may require to be filled in for it to work correctly.{{/configureAuth}}{{^configureAuth}}It can be configured in the [application.yml](src/main/resources/application.yml) using Micronaut security features.{{/configureAuth}}
More information on configuring can be found in [Micronaut Security Guide](https://micronaut-projects.github.io/micronaut-security/latest/guide/#oauth).
{{/isOAuth}}
{{/authMethods}}

View File

@ -0,0 +1,7 @@
# {{classname}}
## Enum
{{#allowableValues}}{{#enumVars}}
* `{{name}}` (value: `{{{value}}}`)
{{/enumVars}}{{/allowableValues}}

View File

@ -0,0 +1,4 @@
{{#models}}{{#model}}
{{#isEnum}}{{>doc/enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>doc/pojo_doc}}{{/isEnum}}
{{/model}}{{/models}}

View File

@ -0,0 +1,39 @@
# {{#vendorExtensions.x-is-one-of-interface}}Interface {{/vendorExtensions.x-is-one-of-interface}}{{classname}}
{{#description}}{{&description}}
{{/description}}
{{^vendorExtensions.x-is-one-of-interface}}
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isContainer}}{{#isArray}}{{#items}}{{#isModel}}[{{/isModel}}{{/items}}`{{baseType}}{{#items}}&lt;{{dataType}}&gt;`{{#isModel}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isModel}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{#isModel}}[{{/isModel}}`Map&lt;String, {{dataType}}&gt;`{{#isModel}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isModel}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{#isModel}}[{{/isModel}}`{{dataType}}`{{#isModel}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isModel}}{{/isContainer}}{{/isEnum}} | {{description}} | {{^required}} [optional property]{{/required}}{{#isReadOnly}} [readonly property]{{/isReadOnly}}
{{/vars}}
{{#vars}}{{#isEnum}}
## Enum: {{datatypeWithEnum}}
Name | Value
---- | -----{{#allowableValues}}{{#enumVars}}
{{name}} | `{{value}}`{{/enumVars}}{{/allowableValues}}
{{/isEnum}}{{/vars}}
{{#vendorExtensions.x-implements.0}}
## Implemented Interfaces
{{#vendorExtensions.x-implements}}
* `{{{.}}}`
{{/vendorExtensions.x-implements}}
{{/vendorExtensions.x-implements.0}}
{{/vendorExtensions.x-is-one-of-interface}}
{{#vendorExtensions.x-is-one-of-interface}}
## Implementing Classes
{{#oneOf}}
* `{{{.}}}`
{{/oneOf}}
{{/vendorExtensions.x-is-one-of-interface}}

View File

@ -0,0 +1 @@
@Generated(value="{{generatorClass}}"{{^hideGenerationTimestamp}}, date="{{generatedDate}}"{{/hideGenerationTimestamp}})

View File

@ -0,0 +1,11 @@
/*
* {{{appName}}}
* {{{appDescription}}}
*
* {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

View File

@ -0,0 +1,52 @@
{{#useBeanValidation}}{{!
validate all pojos and enums
}}{{^isContainer}}{{#isModel}} @Valid
{{/isModel}}{{/isContainer}}{{!
nullable & nonnull
}}{{#required}}{{#isNullable}} @Nullable
{{/isNullable}}{{^isNullable}} @NotNull
{{/isNullable}}{{/required}}{{^required}} @Nullable
{{/required}}{{!
pattern
}}{{#pattern}}{{^isByteArray}} @Pattern(regexp="{{{pattern}}}")
{{/isByteArray}}{{/pattern}}{{!
both minLength && maxLength
}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}}, max={{maxLength}})
{{/maxLength}}{{/minLength}}{{!
just minLength
}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}})
{{/maxLength}}{{/minLength}}{{!
just maxLength
}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}})
{{/maxLength}}{{/minLength}}{{!
@Size: both minItems && maxItems
}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}}, max={{maxItems}})
{{/maxItems}}{{/minItems}}{{!
@Size: just minItems
}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}})
{{/maxItems}}{{/minItems}}{{!
@Size: just maxItems
}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}})
{{/maxItems}}{{/minItems}}{{!
@Email
}}{{#isEmail}} @Email
{{/isEmail}}{{!
check for integer or long / all others=decimal type with @Decimal*
isInteger set
}}{{#isInteger}}{{#minimum}} @Min({{minimum}})
{{/minimum}}{{#maximum}} @Max({{maximum}})
{{/maximum}}{{/isInteger}}{{!
isLong set
}}{{#isLong}}{{#minimum}} @Min({{minimum}}L)
{{/minimum}}{{#maximum}} @Max({{maximum}}L)
{{/maximum}}{{/isLong}}{{!
Not Integer, not Long => we have a decimal value!
}}{{^isInteger}}{{^isLong}}{{!
minimum for decimal value
}}{{#minimum}} @DecimalMin({{#exclusiveMinimum}}value={{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}}, inclusive=false{{/exclusiveMinimum}})
{{/minimum}}{{!
maximal for decimal value
}}{{#maximum}} @DecimalMax({{#exclusiveMaximum}}value={{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}}, inclusive=false{{/exclusiveMaximum}})
{{/maximum}}{{!
close decimal values
}}{{/isLong}}{{/isInteger}}{{/useBeanValidation}}

View File

@ -0,0 +1,26 @@
{{!
If this is map and items are nullable, make sure that nulls are included.
To determine what JsonInclude.Include method to use, consider the following:
* If the field is required, always include it, even if it is null.
* Else use custom behaviour, IOW use whatever is defined on the object mapper
}}
@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
@JsonInclude({{#isMap}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMap}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}})
{{#withXml}}
{{^isContainer}}
@JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
@JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isContainer}}
{{#isContainer}}
{{#isXmlWrapped}}
// items.xmlName={{items.xmlName}}
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}")
{{/isXmlWrapped}}
{{/isContainer}}
{{/withXml}}
{{#isDateTime}}
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXX")
{{/isDateTime}}
{{#isDate}}
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
{{/isDate}}

View File

@ -0,0 +1,48 @@
{{>licenseInfo}}
package {{package}};
{{#useReflectionEqualsHashCode}}
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
{{/useReflectionEqualsHashCode}}
import java.util.Objects;
import java.util.Arrays;
{{#imports}}
import {{import}};
{{/imports}}
{{#serializableModel}}
import java.io.Serializable;
{{/serializableModel}}
import com.fasterxml.jackson.annotation.*;
{{#withXml}}
import com.fasterxml.jackson.dataformat.xml.annotation.*;
import com.fasterxml.jackson.annotation.*;
{{/withXml}}
{{#withXml}}
import javax.xml.bind.annotation.*;
{{/withXml}}
{{#parcelableModel}}
import android.os.Parcelable;
import android.os.Parcel;
{{/parcelableModel}}{{#useBeanValidation}}
import javax.validation.constraints.*;
import javax.validation.Valid;
{{/useBeanValidation}}
import io.micronaut.core.annotation.*;
import javax.annotation.Generated;
{{#models}}
{{#model}}
{{#isEnum}}
{{>model/modelEnum}}
{{/isEnum}}
{{^isEnum}}
{{#vendorExtensions.x-is-one-of-interface}}
{{>model/oneof_interface}}
{{/vendorExtensions.x-is-one-of-interface}}
{{^vendorExtensions.x-is-one-of-interface}}
{{>model/pojo}}
{{/vendorExtensions.x-is-one-of-interface}}
{{/isEnum}}
{{/model}}
{{/models}}

View File

@ -0,0 +1,61 @@
{{#jackson}}
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
{{/jackson}}
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
*/
{{#additionalEnumTypeAnnotations}}
{{{.}}}
{{/additionalEnumTypeAnnotations}}{{#useBeanValidation}}@Introspected
{{/useBeanValidation}}public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
{{#allowableValues}}
{{#enumVars}}
{{#enumDescription}}
/**
* {{enumDescription}}
*/
{{/enumDescription}}
{{#withXml}}
@XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{/withXml}}
{{{name}}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}
{{/allowableValues}}
private {{{dataType}}} value;
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) {
this.value = value;
}
{{#jackson}}
@JsonValue
{{/jackson}}
public {{{dataType}}} getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
{{#jackson}}
@JsonCreator
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (b.value.equals(value)) {
return b;
}
}
{{#isNullable}}
return null;
{{/isNullable}}
{{^isNullable}}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
{{/isNullable}}
}
}

View File

@ -0,0 +1,60 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
*/
{{#withXml}}
@XmlType(name="{{datatypeWithEnum}}")
@XmlEnum({{dataType}}.class)
{{/withXml}}
{{#additionalEnumTypeAnnotations}}
{{{.}}}
{{/additionalEnumTypeAnnotations}}
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}
{{#enumVars}}
{{#enumDescription}}
/**
* {{enumDescription}}
*/
{{/enumDescription}}
{{#withXml}}
@XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{/withXml}}
{{{name}}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}
{{/allowableValues}}
private {{{dataType}}} value;
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{dataType}}} value) {
this.value = value;
}
{{#jackson}}
@JsonValue
{{/jackson}}
public {{{dataType}}} getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
{{#jackson}}
@JsonCreator
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (b.value.equals(value)) {
return b;
}
}
{{#isNullable}}
return null;
{{/isNullable}}
{{^isNullable}}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
{{/isNullable}}
}
}

View File

@ -0,0 +1,9 @@
{{#additionalModelTypeAnnotations}}
{{{.}}}
{{/additionalModelTypeAnnotations}}
{{>generatedAnnotation}}{{>model/typeInfoAnnotation}}{{>model/xmlAnnotation}}
public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {
{{#discriminator}}
public {{propertyType}} {{propertyGetter}}();
{{/discriminator}}
}

View File

@ -0,0 +1,330 @@
/**
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
*/
{{#description}}
@ApiModel(description = "{{{description}}}")
{{/description}}
{{#jackson}}
@JsonPropertyOrder({
{{#vars}}
{{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
{{/vars}}
})
@JsonTypeName("{{name}}")
{{/jackson}}
{{#additionalModelTypeAnnotations}}
{{{.}}}
{{/additionalModelTypeAnnotations}}
{{>generatedAnnotation}}{{#discriminator}}{{>model/typeInfoAnnotation}}{{/discriminator}}{{>model/xmlAnnotation}}{{#useBeanValidation}}
@Introspected
{{/useBeanValidation}}{{!
Declare the class with extends and implements
}}public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}}{
{{#serializableModel}}
private static final long serialVersionUID = 1L;
{{/serializableModel}}
{{#vars}}
{{#isEnum}}
{{^isContainer}}
{{>model/modelInnerEnum}}
{{/isContainer}}
{{#isContainer}}
{{#mostInnerItems}}
{{>model/modelInnerEnum}}
{{/mostInnerItems}}
{{/isContainer}}
{{/isEnum}}
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
{{#withXml}}
{{#isXmlAttribute}}
@XmlAttribute(name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"
{{/isXmlAttribute}}
{{^isXmlAttribute}}
{{^isContainer}}
@XmlElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isContainer}}
{{#isContainer}}
// Is a container wrapped={{isXmlWrapped}}
{{#items}}
// items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}}
// items.example={{example}} items.type={{dataType}}
@XmlElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/items}}
{{#isXmlWrapped}}
@XmlElementWrapper({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlWrapped}}
{{/isContainer}}
{{/isXmlAttribute}}
{{/withXml}}
{{#vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined();
{{/isContainer}}
{{^isContainer}}
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
{{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{/vars}}
{{#parcelableModel}}
public {{classname}}() {
{{#parent}}
super();
{{/parent}}
}
{{/parcelableModel}}
{{#vars}}
{{^isReadOnly}}
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
this.{{name}} = {{name}};
{{/vendorExtensions.x-is-jackson-optional-nullable}}
return this;
}
{{#isArray}}
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().add({{name}}Item);
} catch (java.util.NoSuchElementException e) {
// this can never happen, as we make sure above that the value is present
}
return this;
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.add({{name}}Item);
return this;
{{/vendorExtensions.x-is-jackson-optional-nullable}}
}
{{/isArray}}
{{#isMap}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().put(key, {{name}}Item);
} catch (java.util.NoSuchElementException e) {
// this can never happen, as we make sure above that the value is present
}
return this;
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;
{{/vendorExtensions.x-is-jackson-optional-nullable}}
}
{{/isMap}}
{{/isReadOnly}}
/**
{{#description}}
* {{description}}
{{/description}}
{{^description}}
* Get {{name}}
{{/description}}
{{#minimum}}
* minimum: {{minimum}}
{{/minimum}}
{{#maximum}}
* maximum: {{maximum}}
{{/maximum}}
* @return {{name}}
**/
{{>model/beanValidation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
{{#vendorExtensions.x-extra-annotation}}
{{{vendorExtensions.x-extra-annotation}}}
{{/vendorExtensions.x-extra-annotation}}
{{#vendorExtensions.x-is-jackson-optional-nullable}}
{{!unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}} @JsonIgnore
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#jackson}}
{{>model/jackson_annotations}}{{/jackson}}{{/vendorExtensions.x-is-jackson-optional-nullable}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
{{#isReadOnly}}
{{! A readonly attribute doesn't have setter => jackson will set null directly if explicitly returned by API, so make sure we have an empty JsonNullable}} if ({{name}} == null) {
{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
}
{{/isReadOnly}}
return {{name}}.orElse(null);
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
return {{name}};
{{/vendorExtensions.x-is-jackson-optional-nullable}}
}
{{#vendorExtensions.x-is-jackson-optional-nullable}}
{{>model/jackson_annotations}}
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
return {{name}};
}
@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
{{#isReadOnly}}private{{/isReadOnly}}{{^isReadOnly}}public{{/isReadOnly}} void {{setter}}_JsonNullable(JsonNullable<{{{datatypeWithEnum}}}> {{name}}) {
{{! For getters/setters that have name differing from attribute name, we must include setter (albeit private) for jackson to be able to set the attribute}} this.{{name}} = {{name}};
}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^isReadOnly}}
{{#jackson}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{>model/jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
this.{{name}} = {{name}};
{{/vendorExtensions.x-is-jackson-optional-nullable}}
}
{{/isReadOnly}}
{{/vars}}
@Override
public boolean equals(Object o) {
{{#useReflectionEqualsHashCode}}
return EqualsBuilder.reflectionEquals(this, o, false, null, true);
{{/useReflectionEqualsHashCode}}
{{^useReflectionEqualsHashCode}}
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{^-last}} &&
{{/-last}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};
{{/hasVars}}
{{^hasVars}}
return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};
{{/hasVars}}
{{/useReflectionEqualsHashCode}}
}
@Override
public int hashCode() {
{{#useReflectionEqualsHashCode}}
return HashCodeBuilder.reflectionHashCode(this);
{{/useReflectionEqualsHashCode}}
{{^useReflectionEqualsHashCode}}
return Objects.hash({{#vars}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
{{/useReflectionEqualsHashCode}}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
{{/parent}}
{{#vars}}
sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
{{/vars}}
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private{{#jsonb}} static{{/jsonb}} String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
{{#parcelableModel}}
public void writeToParcel(Parcel out, int flags) {
{{#model}}
{{#isArray}}
out.writeList(this);
{{/isArray}}
{{^isArray}}
{{#parent}}
super.writeToParcel(out, flags);
{{/parent}}
{{#vars}}
out.writeValue({{name}});
{{/vars}}
{{/isArray}}
{{/model}}
}
{{classname}}(Parcel in) {
{{#isArray}}
in.readTypedList(this, {{arrayModelType}}.CREATOR);
{{/isArray}}
{{^isArray}}
{{#parent}}
super(in);
{{/parent}}
{{#vars}}
{{#isPrimitiveType}}
{{name}} = ({{{datatypeWithEnum}}})in.readValue(null);
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{name}} = ({{{datatypeWithEnum}}})in.readValue({{complexType}}.class.getClassLoader());
{{/isPrimitiveType}}
{{/vars}}
{{/isArray}}
}
public int describeContents() {
return 0;
}
public static final Parcelable.Creator<{{classname}}> CREATOR = new Parcelable.Creator<{{classname}}>() {
public {{classname}} createFromParcel(Parcel in) {
{{#model}}
{{#isArray}}
{{classname}} result = new {{classname}}();
result.addAll(in.readArrayList({{arrayModelType}}.class.getClassLoader()));
return result;
{{/isArray}}
{{^isArray}}
return new {{classname}}(in);
{{/isArray}}
{{/model}}
}
public {{classname}}[] newArray(int size) {
return new {{classname}}[size];
}
};
{{/parcelableModel}}
}

View File

@ -0,0 +1,16 @@
{{#jackson}}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true)
{{#discriminator.mappedModels}}
{{#-first}}
@JsonSubTypes({
{{/-first}}
@JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
{{#-last}}
})
{{/-last}}
{{/discriminator.mappedModels}}
{{#isClassnameSanitized}}
@JsonTypeName("{{name}}")
{{/isClassnameSanitized}}
{{/jackson}}

View File

@ -0,0 +1,6 @@
{{#withXml}}
@XmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}")
@XmlAccessorType(XmlAccessType.FIELD)
{{#jackson}}
@JacksonXmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}"){{/jackson}}{{/withXml}}

View File

@ -0,0 +1,46 @@
package {{package}}
{{#imports}}import {{import}}
{{/imports}}
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import spock.lang.Specification
import jakarta.inject.Inject
{{#fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}
/**
* Model tests for {{classname}}
*/
@MicronautTest
public class {{classname}}Spec extends Specification {
{{#models}}
{{#model}}
{{^vendorExtensions.x-is-one-of-interface}}
{{^isEnum}}
private final {{classname}} model = new {{classname}}()
{{/isEnum}}
/**
* Model tests for {{classname}}
*/
void '{{classname}} test'() {
// TODO: test {{classname}}
}
{{#allVars}}
/**
* Test the property '{{name}}'
*/
void '{{classname}} property {{name}} test'() {
// TODO: test {{name}}
}
{{/allVars}}
{{/vendorExtensions.x-is-one-of-interface}}
{{/model}}
{{/models}}
}

View File

@ -0,0 +1,49 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
{{#fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}
/**
* Model tests for {{classname}}
*/
@MicronautTest
public class {{classname}}Test {
{{#models}}
{{#model}}
{{^vendorExtensions.x-is-one-of-interface}}
{{^isEnum}}
private final {{classname}} model = new {{classname}}();
{{/isEnum}}
/**
* Model tests for {{classname}}
*/
@Test
public void test{{classname}}() {
// TODO: test {{classname}}
}
{{#allVars}}
/**
* Test the property '{{name}}'
*/
@Test
public void {{name}}Test() {
// TODO: test {{name}}
}
{{/allVars}}
{{/vendorExtensions.x-is-one-of-interface}}
{{/model}}
{{/models}}
}

View File

@ -0,0 +1,34 @@
{{#useBeanValidation}}{{!
validate all pojos and enums
}}{{^isContainer}}{{#isModel}}@Valid {{/isModel}}{{/isContainer}}{{!
nullable & nonnull
}}{{#required}}@NotNull {{/required}}{{#isNullable}}@Nullable {{/isNullable}}{{!
pattern
}}{{#pattern}}{{^isByteArray}}@Pattern(regexp="{{{pattern}}}") {{/isByteArray}}{{/pattern}}{{!
both minLength && maxLength
}}{{#minLength}}{{#maxLength}}@Size(min={{minLength}}, max={{maxLength}}) {{/maxLength}}{{/minLength}}{{!
just minLength
}}{{#minLength}}{{^maxLength}}@Size(min={{minLength}}) {{/maxLength}}{{/minLength}}{{!
just maxLength
}}{{^minLength}}{{#maxLength}}@Size(max={{maxLength}}) {{/maxLength}}{{/minLength}}{{!
@Size: both minItems && maxItems
}}{{#minItems}}{{#maxItems}}@Size(min={{minItems}}, max={{maxItems}}) {{/maxItems}}{{/minItems}}{{!
@Size: just minItems
}}{{#minItems}}{{^maxItems}}@Size(min={{minItems}}) {{/maxItems}}{{/minItems}}{{!
@Size: just maxItems
}}{{^minItems}}{{#maxItems}}@Size(max={{maxItems}}) {{/maxItems}}{{/minItems}}{{!
@Email
}}{{#isEmail}}@Email{{/isEmail}}{{!
check for integer or long / all others=decimal type with @Decimal*
isInteger set
}}{{#isInteger}}{{#minimum}}@Min({{minimum}}) {{/minimum}}{{#maximum}}@Max({{maximum}}) {{/maximum}}{{/isInteger}}{{!
isLong set
}}{{#isLong}}{{#minimum}}@Min({{minimum}}L) {{/minimum}}{{#maximum}}@Max({{maximum}}L) {{/maximum}}{{/isLong}}{{!
Not Integer, not Long => we have a decimal value!
}}{{^isInteger}}{{^isLong}}{{!
minimum for decimal value
}}{{#minimum}}@DecimalMin({{#exclusiveMinimum}}value={{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}}, inclusive=false{{/exclusiveMinimum}}) {{/minimum}}{{!
maximal for decimal value
}}{{#maximum}}@DecimalMax({{#exclusiveMaximum}}value={{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}}, inclusive=false{{/exclusiveMaximum}}) {{/maximum}}{{!
close decimal values
}}{{/isLong}}{{/isInteger}}{{/useBeanValidation}}

View File

@ -0,0 +1 @@
{{#isBodyParam}}@Body {{>params/beanValidation}}{{>params/type}} {{paramName}}{{/isBodyParam}}

View File

@ -0,0 +1 @@
{{#isCookieParam}}@CookieValue(value="{{baseName}}"{{#defaultValue}}, defaultValue="{{defaultValue}}"{{/defaultValue}}) {{>params/beanValidationCore}}{{>params/type}} {{paramName}}{{/isCookieParam}}

View File

@ -0,0 +1 @@
{{#isFormParam}}{{>params/beanValidation}}{{>params/type}} {{paramName}}{{/isFormParam}}

View File

@ -0,0 +1 @@
{{#isHeaderParam}}@Header(name="{{baseName}}"{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>params/beanValidation}}{{>params/type}} {{paramName}}{{/isHeaderParam}}

View File

@ -0,0 +1 @@
{{#isPathParam}}@PathVariable(name="{{baseName}}"{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>params/beanValidation}}{{>params/type}} {{paramName}}{{/isPathParam}}

View File

@ -0,0 +1 @@
{{#isQueryParam}}@QueryParam(name="{{{baseName}}}"{{!default value}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{!multi format}}{{#isCollectionFormatMulti}}, format=QueryParam.Format.MULTI{{/isCollectionFormatMulti}}{{!deep object}}{{#isDeepObject}}, format=QueryParam.Format.DEEP_OBJECT{{/isDeepObject}}{{!other collection formats}}{{^isCollectionFormatMulti}}{{^isDeepObject}}{{#collectionFormat}}, format=QueryParam.Format.{{#lambda.uppercase}}{{collectionFormat}}{{/lambda.uppercase}}{{/collectionFormat}}{{/isDeepObject}}{{/isCollectionFormatMulti}}) {{!validation and type}}{{>params/beanValidation}}{{>params/type}} {{paramName}}{{/isQueryParam}}

View File

@ -0,0 +1 @@
{{!normal type}}{{^isDate}}{{^isDateTime}}{{{dataType}}}{{/isDateTime}}{{/isDate}}{{!date-time}}{{#isDateTime}}@Format("yyyy-MM-dd'T'HH:mm:ss.SSSXXXX") {{{dataType}}}{{/isDateTime}}{{!date}}{{#isDate}}@Format("yyyy-MM-dd") {{{dataType}}}{{/isDate}}

View File

@ -0,0 +1,78 @@
{{>licenseInfo}}
package {{invokerPackage}}.query;
import io.micronaut.context.annotation.AliasFor;
import io.micronaut.core.bind.annotation.Bindable;
import javax.annotation.Generated;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Indicates that the parameter is a query parameter
*/
{{>generatedAnnotation}}
@Documented
@Retention(RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
@Bindable
@Inherited
public @interface QueryParam {
/**
* @return The name of the parameter
*/
@AliasFor(annotation = Bindable.class, member = "value")
String value() default "";
/**
* @return The name of the parameter
*/
@AliasFor(annotation = Bindable.class, member = "value")
String name() default "";
/**
* @see Bindable#defaultValue()
* @return The default value
*/
@AliasFor(annotation = Bindable.class, member = "defaultValue")
String defaultValue() default "";
/**
* @return The format of the given values in the URL
*/
Format format() default Format.CSV;
/**
* The possible formats of the query parameter in the URL.
* The conversion of various types is according to openapi v3 specification:
* @see <a href="https://swagger.io/specification/">openapi v3 specification</a>
* Values are serialized using Jackson object mapper
*/
public static enum Format {
/**
* The values of iterator are comma-delimited.
* Ambiguity can arise if values of Iterator contain commas inside themselves. In such case, the MUTLI format
* should be preferred.
* Null values are not supported and will be removed during the conversion process.
*/
CSV,
/**
* The values are space-delimited, similarly to comma-delimited format.
*/
SSV,
/**
* The values a delimited by pipes "|", similarly to comma-delimited format.
*/
PIPES,
/**
* The values are repeated as separate parameters, e.g.: color=blue&color=black&color=brown.
*/
MULTI,
/**
* The format supports 1-depth recursion into objects with setting each attribute as a separate parameter, e.g.:
* 'color[R]=100&color[G]=200&color[B]=150'.
*/
DEEP_OBJECT
}
}

View File

@ -0,0 +1,164 @@
{{>licenseInfo}}
package {{invokerPackage}}.query;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.beans.BeanProperty;
import io.micronaut.core.beans.BeanWrapper;
import io.micronaut.core.convert.ArgumentConversionContext;
import io.micronaut.core.convert.ConversionContext;
import io.micronaut.core.convert.ConversionService;
import io.micronaut.core.util.StringUtils;
import io.micronaut.http.MutableHttpRequest;
import io.micronaut.http.client.bind.AnnotatedClientArgumentRequestBinder;
import io.micronaut.http.client.bind.ClientRequestUriContext;
import java.util.Collection;
import java.util.Optional;
import jakarta.inject.Singleton;
import javax.annotation.Generated;
{{>generatedAnnotation}}
@Singleton
public class QueryParamBinder implements AnnotatedClientArgumentRequestBinder<QueryParam> {
private static final Character COMMA_DELIMITER = ',';
private static final Character PIPE_DELIMITER = '|';
private static final Character SPACE_DELIMITER = ' ';
private final ConversionService<?> conversionService;
public QueryParamBinder(ConversionService<?> conversionService) {
this.conversionService = conversionService;
}
@NonNull
@Override
public Class<QueryParam> getAnnotationType() {
return QueryParam.class;
}
@Override
public void bind(@NonNull ArgumentConversionContext<Object> context,
@NonNull ClientRequestUriContext uriContext,
@NonNull Object value,
@NonNull MutableHttpRequest<?> request
) {
String key = context.getAnnotationMetadata().stringValue(QueryParam.class)
.filter(StringUtils::isNotEmpty)
.orElse(context.getArgument().getName());
QueryParam.Format format = context.getAnnotationMetadata()
.enumValue(QueryParam.class, "format", QueryParam.Format.class)
.orElse(QueryParam.Format.CSV);
if (format == QueryParam.Format.DEEP_OBJECT) {
addDeepObjectParameters(context, value, key, uriContext);
} else if (format == QueryParam.Format.MULTI) {
addMultiParameters(context, value, key, uriContext);
} else {
Character delimiter = ' ';
switch (format) {
case SSV:
delimiter = SPACE_DELIMITER;
break;
case PIPES:
delimiter = PIPE_DELIMITER;
break;
case CSV:
delimiter = COMMA_DELIMITER;
break;
default:
}
createSeparatedQueryParam(context, value, delimiter)
.ifPresent(v -> uriContext.addQueryParameter(key, v));
}
}
private void addMultiParameters(
ArgumentConversionContext<Object> context, Object value, String key, ClientRequestUriContext uriContext
) {
if (value instanceof Iterable) {
// noinspection unechecked
Iterable<?> iterable = (Iterable<?>) value;
for (Object item : iterable) {
convertToString(context, item).ifPresent(v -> uriContext.addQueryParameter(key, v));
}
} else {
convertToString(context, value).ifPresent(v -> uriContext.addQueryParameter(key, v));
}
}
private void addDeepObjectParameters(
ArgumentConversionContext<Object> context, Object value, String key, ClientRequestUriContext uriContext
) {
if (value instanceof Iterable) {
StringBuilder builder = new StringBuilder(key);
Iterable<?> iterable = (Iterable<?>) value;
int i = 0;
for (Object item: iterable) {
if (item == null) {
continue;
}
String index = String.valueOf(i);
builder.append('[');
builder.append(index);
builder.append(']');
convertToString(context, item).ifPresent(v -> uriContext.addQueryParameter(builder.toString(), v));
builder.delete(builder.length() - index.length() - 2, builder.length());
i++;
}
} else if (value != null) {
StringBuilder builder = new StringBuilder(key);
BeanWrapper<Object> wrapper = BeanWrapper.getWrapper(value);
Collection<BeanProperty<Object, Object>> properties = wrapper.getBeanProperties();
for (BeanProperty<Object, Object> property: properties) {
Object item = property.get(value);
if (item == null) {
continue;
}
builder.append('[');
builder.append(property.getName());
builder.append(']');
convertToString(context, item).ifPresent(v -> uriContext.addQueryParameter(builder.toString(), v));
builder.delete(builder.length() - property.getName().length() - 2, builder.length());
}
}
}
private Optional<String> createSeparatedQueryParam(
ArgumentConversionContext<Object> context, Object value, Character delimiter
) {
if (value instanceof Iterable) {
StringBuilder builder = new StringBuilder();
// noinspection unechecked
Iterable<?> iterable = (Iterable<?>) value;
boolean first = true;
for (Object item : iterable) {
Optional<String> opt = convertToString(context, item);
if (opt.isPresent()) {
if (!first) {
builder.append(delimiter);
}
first = false;
builder.append(opt.get());
}
}
return Optional.of(builder.toString());
} else {
return convertToString(context, value);
}
}
private Optional<String> convertToString(ArgumentConversionContext<Object> context, Object value) {
return conversionService.convert(value, ConversionContext.STRING.with(context.getAnnotationMetadata()))
.filter(StringUtils::isNotEmpty);
}
}

View File

@ -0,0 +1,250 @@
package org.openapitools.codegen.java.micronaut;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.languages.JavaMicronautClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import static java.util.stream.Collectors.groupingBy;
import static org.testng.Assert.*;
import static org.testng.Assert.fail;
public class MicronautClientCodegenTest {
private final String PETSTORE_PATH = "src/test/resources/petstore.json";
@Test
public void clientOptsUnicity() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.cliOptions()
.stream()
.collect(groupingBy(CliOption::getOpt))
.forEach((k, v) -> assertEquals(v.size(), 1, k + " is described multiple times"));
}
@Test
public void testInitialConfigValues() throws Exception {
final JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.processOpts();
OpenAPI openAPI = new OpenAPI();
openAPI.addServersItem(new Server().url("https://one.com/v2"));
openAPI.setInfo(new Info());
codegen.preprocessOpenAPI(openAPI);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
Assert.assertEquals(codegen.modelPackage(), "org.openapitools.model");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "org.openapitools.model");
Assert.assertEquals(codegen.apiPackage(), "org.openapitools.api");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "org.openapitools.api");
Assert.assertEquals(codegen.getInvokerPackage(), "org.openapitools");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "org.openapitools");
}
@Test
public void doConfigureAuthParam() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_CONFIGURE_AUTH, "true");
String outputPath = generateFiles(codegen, PETSTORE_PATH,
CodegenConstants.SUPPORTING_FILES,
CodegenConstants.APIS);
// Files generated
assertFileExists(outputPath + "/src/main/java/org/openapitools/auth/Authorization.java");
// Endpoints are annotated with @Authorization Bindable
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@Authorization");
}
@Test
public void doNotConfigureAuthParam() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_CONFIGURE_AUTH, "false");
String outputPath = generateFiles(codegen, PETSTORE_PATH,
CodegenConstants.SUPPORTING_FILES,
CodegenConstants.APIS);
// Files are not generated
assertFileNotExists(outputPath + "/src/main/java/org/openapitools/auth/");
assertFileNotContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@Authorization");
}
@Test
public void doUseValidationParam() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_CONFIGURE_AUTH, "false");
String outputPath = generateFiles(codegen, PETSTORE_PATH,
CodegenConstants.APIS);
// Files are not generated
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@Valid");
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@NotNull");
}
@Test
public void doGenerateForMaven() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_BUILD,
JavaMicronautClientCodegen.OPT_BUILD_MAVEN);
String outputPath = generateFiles(codegen, PETSTORE_PATH,
CodegenConstants.SUPPORTING_FILES);
// Files are not generated
assertFileExists(outputPath + "/pom.xml");
assertFileNotExists(outputPath + "/build.gradle");
}
@Test
public void doGenerateForGradle() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_BUILD,
JavaMicronautClientCodegen.OPT_BUILD_GRADLE);
String outputPath = generateFiles(codegen, PETSTORE_PATH,
CodegenConstants.SUPPORTING_FILES);
// Files are not generated
assertFileExists(outputPath + "/build.gradle");
assertFileNotExists(outputPath + "/pom.xml");
}
@Test
public void doGenerateForTestJUnit() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_BUILD,
JavaMicronautClientCodegen.OPT_BUILD_ALL);
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_TEST,
JavaMicronautClientCodegen.OPT_TEST_JUNIT);
String outputPath = generateFiles(codegen, PETSTORE_PATH,
CodegenConstants.SUPPORTING_FILES,
CodegenConstants.API_TESTS, CodegenConstants.APIS, CodegenConstants.MODELS);
// Files are not generated
assertFileContains(outputPath + "build.gradle", "testRuntime(\"junit");
assertFileContains(outputPath + "pom.xml", "<artifactId>micronaut-test-junit");
assertFileNotContains(outputPath + "build.gradle", "testRuntime(\"spock");
assertFileNotContains(outputPath + "pom.xml", "<artifactId>micronaut-test-spock");
assertFileExists(outputPath + "src/test/java/");
assertFileExists(outputPath + "src/test/java/org/openapitools/api/PetApiTest.java");
assertFileContains(outputPath + "src/test/java/org/openapitools/api/PetApiTest.java", "PetApiTest", "@MicronautTest");
}
@Test
public void doGenerateForTestSpock() {
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_BUILD,
JavaMicronautClientCodegen.OPT_BUILD_ALL);
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_TEST,
JavaMicronautClientCodegen.OPT_TEST_SPOCK);
String outputPath = generateFiles(codegen, PETSTORE_PATH,
CodegenConstants.SUPPORTING_FILES,
CodegenConstants.API_TESTS, CodegenConstants.APIS, CodegenConstants.MODELS);
// Files are not generated
assertFileNotContains(outputPath + "build.gradle", "testRuntime(\"junit");
assertFileNotContains(outputPath + "pom.xml", "<artifactId>micronaut-test-junit");
assertFileContains(outputPath + "build.gradle", "testRuntime(\"spock");
assertFileContains(outputPath + "pom.xml", "<artifactId>micronaut-test-spock");
assertFileExists(outputPath + "src/test/groovy");
assertFileExists(outputPath + "src/test/groovy/org/openapitools/api/PetApiSpec.groovy");
assertFileContains(outputPath + "src/test/groovy/org/openapitools/api/PetApiSpec.groovy", "PetApiSpec", "@MicronautTest");
}
/**
*
* @param codegen - the code generator
* @param configPath - the path to the config starting from src/test/resources
* @param filesToGenerate - which files to generate - can be CodegenConstants.MODELS, APIS, SUPPORTING_FILES, ...
* @return - the path to the generated folder
*/
protected String generateFiles(JavaMicronautClientCodegen codegen, String configPath, String... filesToGenerate) {
File output = null;
try {
output = Files.createTempDirectory("test").toFile().getCanonicalFile();
} catch (IOException e) {
fail("Unable to create temporary directory for output");
}
output.deleteOnExit();
// Create parser
String outputPath = output.getAbsolutePath().replace('\\', '/');
OpenAPI openAPI = new OpenAPIParser()
.readLocation(configPath, null, new ParseOptions()).getOpenAPI();
// Configure codegen
codegen.setOutputDir(outputPath);
// Create input
ClientOptInput input = new ClientOptInput();
input.openAPI(openAPI);
input.config(codegen);
// Generate
DefaultGenerator generator = new DefaultGenerator();
// by default nothing is generated
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.API_TESTS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.API_DOCS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
// set all the files user wants to generate
for (String files: filesToGenerate) {
generator.setGeneratorPropertyDefault(files, "true");
}
generator.opts(input).generate();
return outputPath + "/";
}
public static void assertFileContains(String path, String... lines) {
String file = readFile(path);
for (String line : lines)
assertTrue(file.contains(linearize(line)), "File does not contain line [" + line + "]");
}
public static void assertFileNotContains(String path, String... lines) {
String file = readFile(path);
for (String line : lines)
assertFalse(file.contains(linearize(line)), "File contains line [" + line + "]");
}
public static void assertFileExists(String path) {
assertTrue(Paths.get(path).toFile().exists(), "File \"" + path + "\" should exist");
}
public static void assertFileNotExists(String path) {
assertFalse(Paths.get(path).toFile().exists(), "File \"" + path + "\" should not exist");
}
public static String readFile(String path) {
String file = null;
try {
String generatedFile = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8);
file = linearize(generatedFile);
assertNotNull(file);
} catch (IOException e) {
fail("Unable to evaluate file " + path.toString());
}
return file;
}
public static String linearize(String target) {
return target.replaceAll("\r?\n", "").replaceAll("\\s+", "\\s");
}
}

12
pom.xml
View File

@ -775,6 +775,18 @@
<module>samples/client/petstore/scala-httpclient</module> <module>samples/client/petstore/scala-httpclient</module>
</modules> </modules>
</profile> </profile>
<profile>
<id>java-micronaut-client</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/client/petstore/java-micronaut-client</module>
</modules>
</profile>
<profile> <profile>
<id>java-msf4j-server</id> <id>java-msf4j-server</id>
<activation> <activation>

View File

@ -0,0 +1,21 @@
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# exclude jar for gradle wrapper
!gradle/wrapper/*.jar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# build files
**/target
target
.gradle
build

View File

@ -0,0 +1,124 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

View File

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

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,123 @@
.gitignore
.mvn/wrapper/MavenWrapperDownloader.java
.mvn/wrapper/maren-wrapper.properties
.mvn/wrapper/maven-wrapper.jar
README.md
build.gradle
docs/AdditionalPropertiesAnyType.md
docs/AdditionalPropertiesArray.md
docs/AdditionalPropertiesBoolean.md
docs/AdditionalPropertiesClass.md
docs/AdditionalPropertiesInteger.md
docs/AdditionalPropertiesNumber.md
docs/AdditionalPropertiesObject.md
docs/AdditionalPropertiesString.md
docs/Animal.md
docs/AnotherFakeApi.md
docs/ArrayOfArrayOfNumberOnly.md
docs/ArrayOfNumberOnly.md
docs/ArrayTest.md
docs/BigCat.md
docs/BigCatAllOf.md
docs/Capitalization.md
docs/Cat.md
docs/CatAllOf.md
docs/Category.md
docs/ClassModel.md
docs/Dog.md
docs/DogAllOf.md
docs/EnumArrays.md
docs/EnumClass.md
docs/EnumTest.md
docs/FakeApi.md
docs/FakeClassnameTags123Api.md
docs/FileSchemaTestClass.md
docs/FormatTest.md
docs/HasOnlyReadOnly.md
docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md
docs/Model200Response.md
docs/ModelApiResponse.md
docs/ModelClient.md
docs/ModelReturn.md
docs/Name.md
docs/NumberOnly.md
docs/Order.md
docs/OuterComposite.md
docs/OuterEnum.md
docs/Pet.md
docs/PetApi.md
docs/ReadOnlyFirst.md
docs/SpecialModelName.md
docs/StoreApi.md
docs/Tag.md
docs/TypeHolderDefault.md
docs/TypeHolderExample.md
docs/User.md
docs/UserApi.md
docs/XmlItem.md
docs/auth.md
gradle.properties
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
mvnw
mvnw.bat
pom.xml
settings.gradle
src/main/java/org/openapitools/api/AnotherFakeApi.java
src/main/java/org/openapitools/api/FakeApi.java
src/main/java/org/openapitools/api/FakeClassnameTags123Api.java
src/main/java/org/openapitools/api/PetApi.java
src/main/java/org/openapitools/api/StoreApi.java
src/main/java/org/openapitools/api/UserApi.java
src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java
src/main/java/org/openapitools/model/AdditionalPropertiesArray.java
src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java
src/main/java/org/openapitools/model/AdditionalPropertiesClass.java
src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java
src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java
src/main/java/org/openapitools/model/AdditionalPropertiesObject.java
src/main/java/org/openapitools/model/AdditionalPropertiesString.java
src/main/java/org/openapitools/model/Animal.java
src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java
src/main/java/org/openapitools/model/ArrayOfNumberOnly.java
src/main/java/org/openapitools/model/ArrayTest.java
src/main/java/org/openapitools/model/BigCat.java
src/main/java/org/openapitools/model/BigCatAllOf.java
src/main/java/org/openapitools/model/Capitalization.java
src/main/java/org/openapitools/model/Cat.java
src/main/java/org/openapitools/model/CatAllOf.java
src/main/java/org/openapitools/model/Category.java
src/main/java/org/openapitools/model/ClassModel.java
src/main/java/org/openapitools/model/Dog.java
src/main/java/org/openapitools/model/DogAllOf.java
src/main/java/org/openapitools/model/EnumArrays.java
src/main/java/org/openapitools/model/EnumClass.java
src/main/java/org/openapitools/model/EnumTest.java
src/main/java/org/openapitools/model/FileSchemaTestClass.java
src/main/java/org/openapitools/model/FormatTest.java
src/main/java/org/openapitools/model/HasOnlyReadOnly.java
src/main/java/org/openapitools/model/MapTest.java
src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java
src/main/java/org/openapitools/model/Model200Response.java
src/main/java/org/openapitools/model/ModelApiResponse.java
src/main/java/org/openapitools/model/ModelClient.java
src/main/java/org/openapitools/model/ModelReturn.java
src/main/java/org/openapitools/model/Name.java
src/main/java/org/openapitools/model/NumberOnly.java
src/main/java/org/openapitools/model/Order.java
src/main/java/org/openapitools/model/OuterComposite.java
src/main/java/org/openapitools/model/OuterEnum.java
src/main/java/org/openapitools/model/Pet.java
src/main/java/org/openapitools/model/ReadOnlyFirst.java
src/main/java/org/openapitools/model/SpecialModelName.java
src/main/java/org/openapitools/model/Tag.java
src/main/java/org/openapitools/model/TypeHolderDefault.java
src/main/java/org/openapitools/model/TypeHolderExample.java
src/main/java/org/openapitools/model/User.java
src/main/java/org/openapitools/model/XmlItem.java
src/main/java/org/openapitools/query/QueryParam.java
src/main/java/org/openapitools/query/QueryParamBinder.java
src/main/resources/application.yml

View File

@ -0,0 +1 @@
5.2.0-SNAPSHOT

View File

@ -0,0 +1,49 @@
# petstore-micronaut
This is a generated client based on [Micronaut](https://micronaut.io/) framework.
## Configuration
A Micronaut's application can be created by defyning a main class and running:
```java
import io.micronaut.runtime.Micronaut;
import io.micronaut.context.ApplicationContext;
public class Application {
public static void main(String[] args) {
ApplicationContext context = Micronaut.run(Application.class);
}
}
```
More detailed description can be found in the [Micronaut Guide](https://docs.micronaut.io/latest/guide/#ideSetup).
All the properties can be changed in the [application.yml][src/main/resources/application.yml] file or when creating micronaut application as described in [Configuration section of guide](https://docs.micronaut.io/latest/guide/#config).
## Api Guides
Description on how to create Apis is given inside individual api guides:
* [AnotherFakeApi](docs//AnotherFakeApi.md)
* [FakeApi](docs//FakeApi.md)
* [FakeClassnameTags123Api](docs//FakeClassnameTags123Api.md)
* [PetApi](docs//PetApi.md)
* [StoreApi](docs//StoreApi.md)
* [UserApi](docs//UserApi.md)
## Auth methods
Details on auth methods can be found in the [auth.md](doc/auth.md).
## Author

View File

@ -0,0 +1,44 @@
plugins {
id("groovy")
id("com.github.johnrengelman.shadow") version "7.0.0"
id("io.micronaut.application") version "2.0.3"
}
version = "1.0.0"
group = "org.openapitools"
repositories {
mavenCentral()
}
micronaut {
runtime("netty")
testRuntime("spock2")
processing {
incremental(true)
annotations("org.openapitools.*")
}
}
dependencies {
annotationProcessor("io.micronaut:micronaut-http-validation")
annotationProcessor("io.micronaut.security:micronaut-security-annotations")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut:micronaut-validation")
implementation("io.micronaut.security:micronaut-security")
implementation("io.micronaut.security:micronaut-security-oauth2")
implementation("io.micronaut.reactor:micronaut-reactor")
implementation("io.swagger:swagger-annotations:1.5.9")
runtimeOnly("ch.qos.logback:logback-classic")
}
// TODO Set the main class
application {
mainClass.set("org.openapitools.Application")
}
java {
sourceCompatibility = JavaVersion.toVersion("1.8")
targetCompatibility = JavaVersion.toVersion("1.8")
}

View File

@ -0,0 +1,16 @@
# AdditionalPropertiesAnyType
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | `String` | | [optional property]

View File

@ -0,0 +1,16 @@
# AdditionalPropertiesArray
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | `String` | | [optional property]

View File

@ -0,0 +1,16 @@
# AdditionalPropertiesBoolean
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | `String` | | [optional property]

View File

@ -0,0 +1,26 @@
# AdditionalPropertiesClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**mapString** | `Map&lt;String, String&gt;` | | [optional property]
**mapNumber** | `Map&lt;String, BigDecimal&gt;` | | [optional property]
**mapInteger** | `Map&lt;String, Integer&gt;` | | [optional property]
**mapBoolean** | `Map&lt;String, Boolean&gt;` | | [optional property]
**mapArrayInteger** | `Map&lt;String, List&lt;Integer&gt;&gt;` | | [optional property]
**mapArrayAnytype** | `Map&lt;String, List&lt;Object&gt;&gt;` | | [optional property]
**mapMapString** | `Map&lt;String, Map&lt;String, String&gt;&gt;` | | [optional property]
**mapMapAnytype** | `Map&lt;String, Map&lt;String, Object&gt;&gt;` | | [optional property]
**anytype1** | `Object` | | [optional property]
**anytype2** | `Object` | | [optional property]
**anytype3** | `Object` | | [optional property]

View File

@ -0,0 +1,16 @@
# AdditionalPropertiesInteger
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | `String` | | [optional property]

View File

@ -0,0 +1,16 @@
# AdditionalPropertiesNumber
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | `String` | | [optional property]

View File

@ -0,0 +1,16 @@
# AdditionalPropertiesObject
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | `String` | | [optional property]

View File

@ -0,0 +1,16 @@
# AdditionalPropertiesString
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | `String` | | [optional property]

View File

@ -0,0 +1,17 @@
# Animal
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | `String` | |
**color** | `String` | | [optional property]

View File

@ -0,0 +1,62 @@
# AnotherFakeApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
## Creating AnotherFakeApi
To initiate an instance of `AnotherFakeApi`, you can use micronaut's `ApplicationContext`:
```java
/* imports
import io.micronaut.runtime.Micronaut;
import io.micronaut.context.ApplicationContext;
import org.openapitools.api.AnotherFakeApi;
*/
ApplicationContext context = Micronaut.run(/* ... */);
PetApi apiInstance = context.getBean(AnotherFakeApi.class);
```
Or the `@Inject` annotation:
```java
@Singleton
class MyClass {
@Inject
AnotherFakeApi anotherFakeApi;
/* ... use the injected variable */
}
```
Note that the class needs to be annotated with one of Micronaut's [scope annotations](https://docs.micronaut.io/latest/guide/#scopes) like `Singleton` in order to be processed.
More information can be found inside [Inversion of Control guide section](https://docs.micronaut.io/latest/guide/#ioc).
<a name="call123testSpecialTags"></a>
# **call123testSpecialTags**
```java
Mono<ModelClient> AnotherFakeApi.call123testSpecialTags(_body)
```
To test special tags
To test special tags and operation ID starting with number
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | [**ModelClient**](ModelClient.md)| client model |
### Return type
[**ModelClient**](ModelClient.md)
### HTTP request headers
- **Content-Type**: `application/json`
- **Accept**: `application/json`

View File

@ -0,0 +1,16 @@
# ArrayOfArrayOfNumberOnly
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**arrayArrayNumber** | `List&lt;List&lt;BigDecimal&gt;&gt;` | | [optional property]

View File

@ -0,0 +1,16 @@
# ArrayOfNumberOnly
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**arrayNumber** | `List&lt;BigDecimal&gt;` | | [optional property]

View File

@ -0,0 +1,18 @@
# ArrayTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**arrayOfString** | `List&lt;String&gt;` | | [optional property]
**arrayArrayOfInteger** | `List&lt;List&lt;Long&gt;&gt;` | | [optional property]
**arrayArrayOfModel** | `List&lt;List&lt;ReadOnlyFirst&gt;&gt;` | | [optional property]

View File

@ -0,0 +1,26 @@
# BigCat
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**kind** | [**KindEnum**](#KindEnum) | | [optional property]
## Enum: KindEnum
Name | Value
---- | -----
LIONS | `&quot;lions&quot;`
TIGERS | `&quot;tigers&quot;`
LEOPARDS | `&quot;leopards&quot;`
JAGUARS | `&quot;jaguars&quot;`

View File

@ -0,0 +1,26 @@
# BigCatAllOf
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**kind** | [**KindEnum**](#KindEnum) | | [optional property]
## Enum: KindEnum
Name | Value
---- | -----
LIONS | `&quot;lions&quot;`
TIGERS | `&quot;tigers&quot;`
LEOPARDS | `&quot;leopards&quot;`
JAGUARS | `&quot;jaguars&quot;`

View File

@ -0,0 +1,21 @@
# Capitalization
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**smallCamel** | `String` | | [optional property]
**capitalCamel** | `String` | | [optional property]
**smallSnake** | `String` | | [optional property]
**capitalSnake** | `String` | | [optional property]
**scAETHFlowPoints** | `String` | | [optional property]
**ATT_NAME** | `String` | Name of the pet | [optional property]

View File

@ -0,0 +1,16 @@
# Cat
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**declawed** | `Boolean` | | [optional property]

View File

@ -0,0 +1,16 @@
# CatAllOf
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**declawed** | `Boolean` | | [optional property]

View File

@ -0,0 +1,17 @@
# Category
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | `Long` | | [optional property]
**name** | `String` | |

View File

@ -0,0 +1,17 @@
# ClassModel
Model for testing model with \"_class\" property
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**propertyClass** | `String` | | [optional property]

View File

@ -0,0 +1,16 @@
# Dog
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**breed** | `String` | | [optional property]

View File

@ -0,0 +1,16 @@
# DogAllOf
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**breed** | `String` | | [optional property]

View File

@ -0,0 +1,33 @@
# EnumArrays
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**justSymbol** | [**JustSymbolEnum**](#JustSymbolEnum) | | [optional property]
**arrayEnum** | [**List&lt;ArrayEnumEnum&gt;**](#List&lt;ArrayEnumEnum&gt;) | | [optional property]
## Enum: JustSymbolEnum
Name | Value
---- | -----
GREATER_THAN_OR_EQUAL_TO | `&quot;&gt;&#x3D;&quot;`
DOLLAR | `&quot;$&quot;`
## Enum: List&lt;ArrayEnumEnum&gt;
Name | Value
---- | -----
FISH | `&quot;fish&quot;`
CRAB | `&quot;crab&quot;`

View File

@ -0,0 +1,15 @@
# EnumClass
## Enum
* `_ABC` (value: `"_abc"`)
* `_EFG` (value: `"-efg"`)
* `_XYZ_` (value: `"(xyz)"`)

View File

@ -0,0 +1,54 @@
# EnumTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enumString** | [**EnumStringEnum**](#EnumStringEnum) | | [optional property]
**enumStringRequired** | [**EnumStringRequiredEnum**](#EnumStringRequiredEnum) | |
**enumInteger** | [**EnumIntegerEnum**](#EnumIntegerEnum) | | [optional property]
**enumNumber** | [**EnumNumberEnum**](#EnumNumberEnum) | | [optional property]
**outerEnum** | `OuterEnum` | | [optional property]
## Enum: EnumStringEnum
Name | Value
---- | -----
UPPER | `&quot;UPPER&quot;`
LOWER | `&quot;lower&quot;`
EMPTY | `&quot;&quot;`
## Enum: EnumStringRequiredEnum
Name | Value
---- | -----
UPPER | `&quot;UPPER&quot;`
LOWER | `&quot;lower&quot;`
EMPTY | `&quot;&quot;`
## Enum: EnumIntegerEnum
Name | Value
---- | -----
NUMBER_1 | `1`
NUMBER_MINUS_1 | `-1`
## Enum: EnumNumberEnum
Name | Value
---- | -----
NUMBER_1_DOT_1 | `1.1`
NUMBER_MINUS_1_DOT_2 | `-1.2`

View File

@ -0,0 +1,417 @@
# FakeApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**createXmlItem**](FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
[**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema |
[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params |
[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \&quot;client\&quot; model
[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
[**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-paramters |
## Creating FakeApi
To initiate an instance of `FakeApi`, you can use micronaut's `ApplicationContext`:
```java
/* imports
import io.micronaut.runtime.Micronaut;
import io.micronaut.context.ApplicationContext;
import org.openapitools.api.FakeApi;
*/
ApplicationContext context = Micronaut.run(/* ... */);
PetApi apiInstance = context.getBean(FakeApi.class);
```
Or the `@Inject` annotation:
```java
@Singleton
class MyClass {
@Inject
FakeApi fakeApi;
/* ... use the injected variable */
}
```
Note that the class needs to be annotated with one of Micronaut's [scope annotations](https://docs.micronaut.io/latest/guide/#scopes) like `Singleton` in order to be processed.
More information can be found inside [Inversion of Control guide section](https://docs.micronaut.io/latest/guide/#ioc).
<a name="createXmlItem"></a>
# **createXmlItem**
```java
Mono<Void> FakeApi.createXmlItem(xmlItem)
```
creates an XmlItem
this route creates an XmlItem
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**xmlItem** | [**XmlItem**](XmlItem.md)| XmlItem Body |
### HTTP request headers
- **Content-Type**: `application/xml`, `application/xml; charset=utf-8`, `application/xml; charset=utf-16`, `text/xml`, `text/xml; charset=utf-8`, `text/xml; charset=utf-16`
- **Accept**: Not defined
<a name="fakeOuterBooleanSerialize"></a>
# **fakeOuterBooleanSerialize**
```java
Mono<Boolean> FakeApi.fakeOuterBooleanSerialize(_body)
```
Test serialization of outer boolean types
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | `Boolean`| Input boolean as post body | [optional parameter]
### Return type
`Boolean`
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: `*/*`
<a name="fakeOuterCompositeSerialize"></a>
# **fakeOuterCompositeSerialize**
```java
Mono<OuterComposite> FakeApi.fakeOuterCompositeSerialize(_body)
```
Test serialization of object with outer number type
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional parameter]
### Return type
[**OuterComposite**](OuterComposite.md)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: `*/*`
<a name="fakeOuterNumberSerialize"></a>
# **fakeOuterNumberSerialize**
```java
Mono<BigDecimal> FakeApi.fakeOuterNumberSerialize(_body)
```
Test serialization of outer number types
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | `BigDecimal`| Input number as post body | [optional parameter]
### Return type
[**BigDecimal**](BigDecimal.md)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: `*/*`
<a name="fakeOuterStringSerialize"></a>
# **fakeOuterStringSerialize**
```java
Mono<String> FakeApi.fakeOuterStringSerialize(_body)
```
Test serialization of outer string types
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | `String`| Input string as post body | [optional parameter]
### Return type
`String`
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: `*/*`
<a name="testBodyWithFileSchema"></a>
# **testBodyWithFileSchema**
```java
Mono<Void> FakeApi.testBodyWithFileSchema(_body)
```
For this test, the body for this request much reference a schema named &#x60;File&#x60;.
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
### HTTP request headers
- **Content-Type**: `application/json`
- **Accept**: Not defined
<a name="testBodyWithQueryParams"></a>
# **testBodyWithQueryParams**
```java
Mono<Void> FakeApi.testBodyWithQueryParams(query_body)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**query** | `String`| |
**_body** | [**User**](User.md)| |
### HTTP request headers
- **Content-Type**: `application/json`
- **Accept**: Not defined
<a name="testClientModel"></a>
# **testClientModel**
```java
Mono<ModelClient> FakeApi.testClientModel(_body)
```
To test \&quot;client\&quot; model
To test \&quot;client\&quot; model
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | [**ModelClient**](ModelClient.md)| client model |
### Return type
[**ModelClient**](ModelClient.md)
### HTTP request headers
- **Content-Type**: `application/json`
- **Accept**: `application/json`
<a name="testEndpointParameters"></a>
# **testEndpointParameters**
```java
Mono<Void> FakeApi.testEndpointParameters(number_doublepatternWithoutDelimiter_byteintegerint32int64_floatstringbinarydatedateTimepasswordparamCallback)
```
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**number** | `BigDecimal`| None |
**_double** | `Double`| None |
**patternWithoutDelimiter** | `String`| None |
**_byte** | `byte[]`| None |
**integer** | `Integer`| None | [optional parameter]
**int32** | `Integer`| None | [optional parameter]
**int64** | `Long`| None | [optional parameter]
**_float** | `Float`| None | [optional parameter]
**string** | `String`| None | [optional parameter]
**binary** | `File`| None | [optional parameter]
**date** | `LocalDate`| None | [optional parameter]
**dateTime** | `LocalDateTime`| None | [optional parameter]
**password** | `String`| None | [optional parameter]
**paramCallback** | `String`| None | [optional parameter]
### Authorization
* **[http_basic_test](auth.md#http_basic_test)**
### HTTP request headers
- **Content-Type**: `application/x-www-form-urlencoded`
- **Accept**: Not defined
<a name="testEnumParameters"></a>
# **testEnumParameters**
```java
Mono<Void> FakeApi.testEnumParameters(enumHeaderStringArrayenumHeaderStringenumQueryStringArrayenumQueryStringenumQueryIntegerenumQueryDoubleenumFormStringArrayenumFormString)
```
To test enum parameters
To test enum parameters
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**enumHeaderStringArray** | [**List&lt;String&gt;**](String.md)| Header parameter enum test (string array) | [optional parameter] [enum: `>`, `$`]
**enumHeaderString** | `String`| Header parameter enum test (string) | [optional parameter] [default to `-efg`] [enum: `_abc`, `-efg`, `(xyz)`]
**enumQueryStringArray** | [**List&lt;String&gt;**](String.md)| Query parameter enum test (string array) | [optional parameter] [enum: `>`, `$`]
**enumQueryString** | `String`| Query parameter enum test (string) | [optional parameter] [default to `-efg`] [enum: `_abc`, `-efg`, `(xyz)`]
**enumQueryInteger** | `Integer`| Query parameter enum test (double) | [optional parameter] [enum: `1`, `-2`]
**enumQueryDouble** | `Double`| Query parameter enum test (double) | [optional parameter] [enum: `1.1`, `-1.2`]
**enumFormStringArray** | [**List&lt;String&gt;**](String.md)| Form parameter enum test (string array) | [optional parameter] [default to `$`] [enum: `>`, `$`]
**enumFormString** | `String`| Form parameter enum test (string) | [optional parameter] [default to `-efg`] [enum: `_abc`, `-efg`, `(xyz)`]
### HTTP request headers
- **Content-Type**: `application/x-www-form-urlencoded`
- **Accept**: Not defined
<a name="testGroupParameters"></a>
# **testGroupParameters**
```java
Mono<Void> FakeApi.testGroupParameters(requiredStringGrouprequiredBooleanGrouprequiredInt64GroupstringGroupbooleanGroupint64Group)
```
Fake endpoint to test group parameters (optional)
Fake endpoint to test group parameters (optional)
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**requiredStringGroup** | `Integer`| Required String in group parameters |
**requiredBooleanGroup** | `Boolean`| Required Boolean in group parameters |
**requiredInt64Group** | `Long`| Required Integer in group parameters |
**stringGroup** | `Integer`| String in group parameters | [optional parameter]
**booleanGroup** | `Boolean`| Boolean in group parameters | [optional parameter]
**int64Group** | `Long`| Integer in group parameters | [optional parameter]
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="testInlineAdditionalProperties"></a>
# **testInlineAdditionalProperties**
```java
Mono<Void> FakeApi.testInlineAdditionalProperties(param)
```
test inline additionalProperties
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**param** | [**Map&lt;String, String&gt;**](String.md)| request body |
### HTTP request headers
- **Content-Type**: `application/json`
- **Accept**: Not defined
<a name="testJsonFormData"></a>
# **testJsonFormData**
```java
Mono<Void> FakeApi.testJsonFormData(paramparam2)
```
test json serialization of form data
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**param** | `String`| field1 |
**param2** | `String`| field2 |
### HTTP request headers
- **Content-Type**: `application/x-www-form-urlencoded`
- **Accept**: Not defined
<a name="testQueryParameterCollectionFormat"></a>
# **testQueryParameterCollectionFormat**
```java
Mono<Void> FakeApi.testQueryParameterCollectionFormat(pipeioutilhttpurlcontext)
```
To test the collection format in query parameters
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pipe** | [**List&lt;String&gt;**](String.md)| |
**ioutil** | [**List&lt;String&gt;**](String.md)| |
**http** | [**List&lt;String&gt;**](String.md)| |
**url** | [**List&lt;String&gt;**](String.md)| |
**context** | [**List&lt;String&gt;**](String.md)| |
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined

View File

@ -0,0 +1,63 @@
# FakeClassnameTags123Api
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
## Creating FakeClassnameTags123Api
To initiate an instance of `FakeClassnameTags123Api`, you can use micronaut's `ApplicationContext`:
```java
/* imports
import io.micronaut.runtime.Micronaut;
import io.micronaut.context.ApplicationContext;
import org.openapitools.api.FakeClassnameTags123Api;
*/
ApplicationContext context = Micronaut.run(/* ... */);
PetApi apiInstance = context.getBean(FakeClassnameTags123Api.class);
```
Or the `@Inject` annotation:
```java
@Singleton
class MyClass {
@Inject
FakeClassnameTags123Api fakeClassnameTags123Api;
/* ... use the injected variable */
}
```
Note that the class needs to be annotated with one of Micronaut's [scope annotations](https://docs.micronaut.io/latest/guide/#scopes) like `Singleton` in order to be processed.
More information can be found inside [Inversion of Control guide section](https://docs.micronaut.io/latest/guide/#ioc).
<a name="testClassname"></a>
# **testClassname**
```java
Mono<ModelClient> FakeClassnameTags123Api.testClassname(_body)
```
To test class name in snake case
To test class name in snake case
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_body** | [**ModelClient**](ModelClient.md)| client model |
### Return type
[**ModelClient**](ModelClient.md)
### Authorization
* **[api_key_query](auth.md#api_key_query)**
### HTTP request headers
- **Content-Type**: `application/json`
- **Accept**: `application/json`

View File

@ -0,0 +1,17 @@
# FileSchemaTestClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file** | [`java.io.File`](java.io.File.md) | | [optional property]
**files** | [`List&lt;java.io.File&gt;`](java.io.File.md) | | [optional property]

View File

@ -0,0 +1,29 @@
# FormatTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**integer** | `Integer` | | [optional property]
**int32** | `Integer` | | [optional property]
**int64** | `Long` | | [optional property]
**number** | `BigDecimal` | |
**_float** | `Float` | | [optional property]
**_double** | `Double` | | [optional property]
**string** | `String` | | [optional property]
**_byte** | `byte[]` | |
**binary** | `File` | | [optional property]
**date** | `LocalDate` | |
**dateTime** | `LocalDateTime` | | [optional property]
**uuid** | `UUID` | | [optional property]
**password** | `String` | |
**bigDecimal** | `BigDecimal` | | [optional property]

View File

@ -0,0 +1,17 @@
# HasOnlyReadOnly
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bar** | `String` | | [optional property] [readonly property]
**foo** | `String` | | [optional property] [readonly property]

Some files were not shown because too many files have changed in this diff Show More