forked from loafle/openapi-generator-original
* InlineResolver to flatten callback operations Signed-off-by: lwlee2608 <lwlee2608@gmail.com> * clone from VertxServerCodegen, to new VertxWebServerCodegen * fix compilation error in VertxWebCodegn * Start working on VertxWebServerCodegen, adding support files * add server api handler * add server api and fix yaml spec file generation * link api to apiHandler * convert vertx parameters into API model * add support to multipart/form-data upload files * ability to set http status code from ApiImpl * replace rootPackage with invokerPackage * add readme and sample * fix circleCi error * override file to FileUpload in typeMapping, no need to override from fromOperation(). Also remove unused annotation import from model * remove smartBear software copyright * use {{artifactVersion}} instead of hardcode version in readme * add -t flag in generation script * add generated vertx-web server to master pom for testing
This commit is contained in:
parent
4543c21030
commit
0f2272d9a4
37
bin/java-vertx-web-rx-petstore-server.sh
Executable file
37
bin/java-vertx-web-rx-petstore-server.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
SPEC="modules/openapi-generator/src/test/resources/3_0/petstore.yaml"
|
||||
GENERATOR="java-vertx-web"
|
||||
TEMPLATE="modules/openapi-generator/src/main/resources/JavaVertXWebServer"
|
||||
STUB_DIR="samples/server/petstore/java-vertx-web/rx"
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i $SPEC -t $TEMPLATE -g $GENERATOR --artifact-id java-vertx-web-rx-server -o $STUB_DIR --additional-properties hideGenerationTimestamp=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -88,6 +88,7 @@ The following generators are available:
|
||||
* [java-play-framework](generators/java-play-framework.md)
|
||||
* [java-undertow-server](generators/java-undertow-server.md)
|
||||
* [java-vertx](generators/java-vertx.md)
|
||||
* [java-vertx-web](generators/java-vertx-web.md)
|
||||
* [jaxrs-cxf](generators/jaxrs-cxf.md)
|
||||
* [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi.md)
|
||||
* [jaxrs-cxf-extended](generators/jaxrs-cxf-extended.md)
|
||||
|
42
docs/generators/java-vertx-web.md
Normal file
42
docs/generators/java-vertx-web.md
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
title: Config Options for java-vertx-web
|
||||
sidebar_label: java-vertx-web
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|modelPackage|package for generated models| |org.openapitools.vertxweb.server.model|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.vertxweb.server.api|
|
||||
|invokerPackage|root package for generated code| |org.openapitools.vertxweb.server|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-java-vertx-web-server|
|
||||
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0-SNAPSHOT|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|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|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|licenseName|The name of the license| |Unlicense|
|
||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||
|sourceFolder|source folder for generated code| |src/main/java|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |false|
|
||||
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date (if you really have a good reason not to use threetenbp</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+) - note: this also sets "java8" to true</dd><dt>**threetenbp**</dt><dd>Backport of JSR310 (preferred for jdk < 1.8)</dd><dl>|java8|
|
||||
|java8|Option. Use Java8 classes instead of third party equivalents|<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>|false|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|
||||
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|
||||
|parentArtifactId|parent artifactId 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|
|
||||
|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|
|
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class JavaVertXWebServerCodegen extends AbstractJavaCodegen {
|
||||
|
||||
protected String resourceFolder = "src/main/resources";
|
||||
protected String apiVersion = "1.0.0-SNAPSHOT";
|
||||
|
||||
public JavaVertXWebServerCodegen() {
|
||||
super();
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code" + File.separator + "javaVertXServer";
|
||||
|
||||
modelTemplateFiles.clear();
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
|
||||
apiTemplateFiles.clear();
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
apiTemplateFiles.put("apiImpl.mustache", "Impl.java");
|
||||
apiTemplateFiles.put("apiHandler.mustache", "Handler.java");
|
||||
|
||||
embeddedTemplateDir = templateDir = "JavaVertXWebServer";
|
||||
|
||||
invokerPackage = "org.openapitools.vertxweb.server";
|
||||
apiPackage = invokerPackage + ".api";
|
||||
modelPackage = invokerPackage + ".model";
|
||||
artifactId = "openapi-java-vertx-web-server";
|
||||
artifactVersion = apiVersion;
|
||||
this.setDateLibrary("java8");
|
||||
|
||||
// clioOptions default redifinition need to be updated
|
||||
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
|
||||
updateOption(CodegenConstants.ARTIFACT_VERSION, this.getArtifactVersion());
|
||||
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||
updateOption(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
updateOption(this.DATE_LIBRARY, this.getDateLibrary());
|
||||
|
||||
// Override type mapping
|
||||
typeMapping.put("file", "FileUpload");
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "java-vertx-web";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Java Vert.x-Web Server.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
apiTestTemplateFiles.clear();
|
||||
|
||||
importMapping.remove("JsonCreator");
|
||||
importMapping.remove("com.fasterxml.jackson.annotation.JsonProperty");
|
||||
importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude");
|
||||
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
|
||||
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
||||
importMapping.put("FileUpload", "io.vertx.ext.web.FileUpload");
|
||||
|
||||
modelDocTemplateFiles.clear();
|
||||
apiDocTemplateFiles.clear();
|
||||
|
||||
String sourcePackageFolder = sourceFolder + File.separator + invokerPackage.replace(".", File.separator);
|
||||
supportingFiles.clear();
|
||||
supportingFiles.add(new SupportingFile("supportFiles/openapi.mustache", resourceFolder, "openapi.yaml"));
|
||||
supportingFiles.add(new SupportingFile("supportFiles/HttpServerVerticle.mustache", sourcePackageFolder, "HttpServerVerticle.java"));
|
||||
supportingFiles.add(new SupportingFile("supportFiles/MainVerticle.mustache", sourcePackageFolder, "MainVerticle.java"));
|
||||
supportingFiles.add(new SupportingFile("supportFiles/ApiResponse.mustache", sourcePackageFolder, "ApiResponse.java"));
|
||||
supportingFiles.add(new SupportingFile("supportFiles/ApiException.mustache", sourcePackageFolder, "ApiException.java"));
|
||||
supportingFiles.add(new SupportingFile("supportFiles/ParameterCast.mustache", sourcePackageFolder, "ParameterCast.java"));
|
||||
supportingFiles.add(new SupportingFile("supportFiles/pom.mustache", "", "pom.xml"));
|
||||
|
||||
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
if (!model.isEnum) {
|
||||
model.imports.add("JsonInclude");
|
||||
model.imports.add("JsonProperty");
|
||||
if (model.hasEnums) {
|
||||
model.imports.add("JsonValue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> newObjs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) newObjs.get("operations");
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||
|
||||
if (operation.returnType == null) {
|
||||
operation.returnType = "Void";
|
||||
}
|
||||
}
|
||||
}
|
||||
return newObjs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateYAMLSpecFile(objs);
|
||||
return super.postProcessSupportingFileData(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenModel fromModel(String name, Schema model) {
|
||||
CodegenModel codegenModel = super.fromModel(name, model);
|
||||
codegenModel.imports.remove("ApiModel");
|
||||
codegenModel.imports.remove("ApiModelProperty");
|
||||
return codegenModel;
|
||||
}
|
||||
}
|
14
modules/openapi-generator/src/main/resources/JavaVertXWebServer/README.mustache
vendored
Normal file
14
modules/openapi-generator/src/main/resources/JavaVertXWebServer/README.mustache
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
{{^hideGenerationTimestamp}}
|
||||
Project generated on : {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
|
||||
## Getting Started
|
||||
|
||||
This document assumes you have maven available.
|
||||
|
||||
To build the project using maven, run:
|
||||
```bash
|
||||
mvn package && java -jar target/target/java-vertx-web-rx-server-{{artifactVersion}}-fat.jar
|
||||
```
|
||||
|
||||
If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:8080/)
|
19
modules/openapi-generator/src/main/resources/JavaVertXWebServer/api.mustache
vendored
Normal file
19
modules/openapi-generator/src/main/resources/JavaVertXWebServer/api.mustache
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import {{invokerPackage}}.ApiResponse;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface {{classname}} {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
Single<ApiResponse<{{{returnType}}}>> {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/allParams}});
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
95
modules/openapi-generator/src/main/resources/JavaVertXWebServer/apiHandler.mustache
vendored
Normal file
95
modules/openapi-generator/src/main/resources/JavaVertXWebServer/apiHandler.mustache
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import {{invokerPackage}}.ParameterCast;
|
||||
import {{invokerPackage}}.ApiException;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.http.HttpServerResponse;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class {{classname}}Handler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger({{classname}}Handler.class);
|
||||
private {{classname}} apiImpl = new {{classname}}Impl();
|
||||
|
||||
public {{classname}}Handler(Map<String, Handler<RoutingContext>> operationHandlers) {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
operationHandlers.put("{{operationId}}", this::{{operationId}});
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
private void {{operationId}}(RoutingContext routingContext) {
|
||||
logger.info("{{operationId}}()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
{{#returnType}}Single{{/returnType}}{{^returnType}}Completable{{/returnType}}.defer( () -> {
|
||||
{{#allParams}}
|
||||
{{^isBodyParam}}
|
||||
{{^isListContainer}}
|
||||
{{#isHeaderParam}}
|
||||
{{{dataType}}} {{paramName}} = ParameterCast.to{{dataType}}(routingContext.request().getHeader("{{baseName}}"));
|
||||
{{/isHeaderParam}}
|
||||
{{#isPathParam}}
|
||||
{{{dataType}}} {{paramName}} = ParameterCast.to{{dataType}}(routingContext.pathParams().get("{{baseName}}"));
|
||||
{{/isPathParam}}
|
||||
{{#isQueryParam}}
|
||||
{{{dataType}}} {{paramName}} = ParameterCast.to{{dataType}}(routingContext.queryParams().get("{{baseName}}"));
|
||||
{{/isQueryParam}}
|
||||
{{#isFormParam}}
|
||||
{{^isFile}}
|
||||
{{{dataType}}} {{paramName}} = ParameterCast.to{{dataType}}(routingContext.request().getFormAttribute("{{baseName}}"));
|
||||
{{/isFile}}
|
||||
{{#isFile}}
|
||||
{{{dataType}}} {{paramName}} = routingContext.fileUploads().iterator().next();
|
||||
{{/isFile}}
|
||||
{{/isFormParam}}
|
||||
{{/isListContainer}}
|
||||
{{#isListContainer}}
|
||||
{{{dataType}}} {{paramName}} = routingContext.request().params().getAll("{{baseName}}");
|
||||
{{/isListContainer}}
|
||||
{{/isBodyParam}}
|
||||
{{/allParams}}
|
||||
{{#allParams}}
|
||||
{{#isBodyParam}}
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
{{{dataType}}} {{paramName}} = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<{{{dataType}}}>(){});
|
||||
{{/isBodyParam}}
|
||||
{{/allParams}}
|
||||
{{#allParams}}
|
||||
logger.info("Parameter {{paramName}} is {}", {{paramName}});
|
||||
{{/allParams}}
|
||||
return apiImpl.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
25
modules/openapi-generator/src/main/resources/JavaVertXWebServer/apiImpl.mustache
vendored
Normal file
25
modules/openapi-generator/src/main/resources/JavaVertXWebServer/apiImpl.mustache
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import {{invokerPackage}}.ApiResponse;
|
||||
import {{invokerPackage}}.ApiException;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Implement this class
|
||||
|
||||
public class {{classname}}Impl implements {{classname}} {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
public Single<ApiResponse<{{{returnType}}}>> {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
17
modules/openapi-generator/src/main/resources/JavaVertXWebServer/enumClass.mustache
vendored
Normal file
17
modules/openapi-generator/src/main/resources/JavaVertXWebServer/enumClass.mustache
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
public enum {{{datatypeWithEnum}}} {
|
||||
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
|
||||
private String value;
|
||||
|
||||
{{{datatypeWithEnum}}}(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
36
modules/openapi-generator/src/main/resources/JavaVertXWebServer/enumOuterClass.mustache
vendored
Normal file
36
modules/openapi-generator/src/main/resources/JavaVertXWebServer/enumOuterClass.mustache
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
|
||||
*/
|
||||
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
{{{name}}}({{{value}}}){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
|
||||
private {{{dataType}}} value;
|
||||
|
||||
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public {{{dataType}}} getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
{{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/useNullForUnknownEnumValue}}
|
||||
}
|
||||
}
|
12
modules/openapi-generator/src/main/resources/JavaVertXWebServer/model.mustache
vendored
Normal file
12
modules/openapi-generator/src/main/resources/JavaVertXWebServer/model.mustache
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
package {{package}};
|
||||
|
||||
import java.util.Objects;
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
{{#serializableModel}}import java.io.Serializable;
|
||||
{{/serializableModel}}{{#models}}{{#model}}{{#description}}
|
||||
/**
|
||||
* {{description}}
|
||||
**/
|
||||
{{/description}}{{^description}}
|
||||
{{/description}}{{#isEnum}}{{>enumOuterClass}}{{/isEnum}}{{^isEnum}}{{>pojo}}{{/isEnum}}{{/model}}{{/models}}
|
71
modules/openapi-generator/src/main/resources/JavaVertXWebServer/pojo.mustache
vendored
Normal file
71
modules/openapi-generator/src/main/resources/JavaVertXWebServer/pojo.mustache
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||
{{#vars}}{{#isEnum}}{{^isContainer}}
|
||||
|
||||
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
|
||||
|
||||
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/vars}}
|
||||
|
||||
public {{classname}} () {
|
||||
|
||||
}
|
||||
|
||||
public {{classname}} ({{#vars}}{{{datatypeWithEnum}}} {{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}) {
|
||||
{{#vars}}
|
||||
this.{{name}} = {{name}};
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
{{#vars}}
|
||||
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
|
||||
@JsonProperty("{{baseName}}")
|
||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
|
||||
{{/vars}}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||
return true;{{/hasVars}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||
}
|
||||
|
||||
@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 String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
public class ApiException extends RuntimeException {
|
||||
private final String message;
|
||||
private Integer statusCode;
|
||||
|
||||
public ApiException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ApiException setStatusCode(Integer statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
public class ApiResponse<T> {
|
||||
private final T data;
|
||||
private Integer statusCode;
|
||||
|
||||
public ApiResponse(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ApiResponse() {
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ApiResponse<T> setStatusCode(Integer statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.http.HttpServerOptions;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import io.vertx.ext.web.api.contract.RouterFactoryOptions;
|
||||
import io.vertx.reactivex.core.AbstractVerticle;
|
||||
import io.vertx.reactivex.ext.web.api.contract.openapi3.OpenAPI3RouterFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
{{#apiInfo}}{{#apis}}
|
||||
import {{apiPackage}}.{{classname}}Handler;{{/apis}}{{/apiInfo}}
|
||||
|
||||
public class HttpServerVerticle extends AbstractVerticle {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpServerVerticle.class);
|
||||
|
||||
private static String specFile = "src/main/resources/openapi.yaml";
|
||||
|
||||
private Map<String, Handler<RoutingContext>> operationHandlers = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void start(Future<Void> fut) {
|
||||
{{#apiInfo}}{{#apis}}
|
||||
new {{classname}}Handler(operationHandlers);{{/apis}}{{/apiInfo}}
|
||||
|
||||
OpenAPI3RouterFactory.rxCreate(vertx, specFile)
|
||||
.doOnSuccess(factory -> {
|
||||
factory.setOptions(new RouterFactoryOptions()
|
||||
.setRequireSecurityHandlers(false)
|
||||
.setMountNotImplementedHandler(false));
|
||||
factory.setValidationFailureHandler(this::validationFailureHandler);
|
||||
operationHandlers.forEach(factory.getDelegate()::addHandlerByOperationId);
|
||||
})
|
||||
.map(OpenAPI3RouterFactory::getRouter)
|
||||
.doOnSuccess(router -> router.route().last().handler(this::methodNotFoundHandler))
|
||||
.map(router ->
|
||||
vertx.createHttpServer(new HttpServerOptions()
|
||||
.setPort(8080)
|
||||
.setHost("localhost"))
|
||||
.requestHandler(router)
|
||||
.listen()
|
||||
)
|
||||
.subscribe( httpServer -> {
|
||||
logger.info("Http verticle deployed successful");
|
||||
fut.complete();
|
||||
}, error -> {
|
||||
logger.info("Http verticle failed to deployed", error);
|
||||
fut.fail(error.getCause());
|
||||
});
|
||||
}
|
||||
|
||||
private void validationFailureHandler(io.vertx.reactivex.ext.web.RoutingContext rc) {
|
||||
rc.response().setStatusCode(400)
|
||||
.end("Bad Request : " + rc.failure().getMessage());
|
||||
}
|
||||
|
||||
private void methodNotFoundHandler(io.vertx.reactivex.ext.web.RoutingContext rc) {
|
||||
rc.response().setStatusCode(404)
|
||||
.end("Method '" + rc.request().path() + "' Not Found");
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
import io.vertx.core.DeploymentOptions;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.reactivex.core.AbstractVerticle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MainVerticle extends AbstractVerticle {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MainVerticle.class);
|
||||
|
||||
@Override
|
||||
public void start(Future<Void> future) {
|
||||
|
||||
DeploymentOptions options = new DeploymentOptions();
|
||||
options.setInstances(Runtime.getRuntime().availableProcessors());
|
||||
|
||||
vertx.deployVerticle(HttpServerVerticle.class.getName(), options, res -> {
|
||||
if (!res.succeeded()) {
|
||||
logger.error("Deployment fail reason: ", res.cause());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,88 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.Json;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class ParameterCast {
|
||||
|
||||
public static Boolean toBoolean(String str) {
|
||||
if (str != null) {
|
||||
return Boolean.parseBoolean(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static UUID toUUID(String str) {
|
||||
if (str != null) {
|
||||
return UUID.fromString(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer toInteger(String str) {
|
||||
if (str != null) {
|
||||
return Integer.parseInt(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Long toLong(String str) {
|
||||
if (str != null) {
|
||||
return Long.parseLong(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Double toDouble(String str) {
|
||||
if (str != null){
|
||||
return Double.parseDouble(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Float toFloat(String str) {
|
||||
if (str != null){
|
||||
return Float.parseFloat(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static OffsetDateTime toOffsetDateTime(String str) {
|
||||
if (str != null) {
|
||||
return OffsetDateTime.parse(str,
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String toString(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
public static <T> T toObject(String str) {
|
||||
if (str != null) {
|
||||
return Json.decodeValue(str, new TypeReference<T>(){});
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T toObject(String str, Class<T> classz) {
|
||||
if (str != null) {
|
||||
return Json.decodeValue(str, classz);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
{{{openapi-yaml}}}
|
102
modules/openapi-generator/src/main/resources/JavaVertXWebServer/supportFiles/pom.mustache
vendored
Normal file
102
modules/openapi-generator/src/main/resources/JavaVertXWebServer/supportFiles/pom.mustache
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>{{groupId}}</groupId>
|
||||
<artifactId>{{artifactId}}</artifactId>
|
||||
<version>{{artifactVersion}}</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>{{appName}}</name>
|
||||
|
||||
<properties>
|
||||
<vertx.version>3.6.3</vertx.version>
|
||||
<slf4j.version>1.7.26</slf4j.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-web</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-web-api-contract</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-rx-java2</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.reactivex.rxjava2</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<manifestEntries>
|
||||
<Main-Class>io.vertx.core.Starter</Main-Class>
|
||||
<Main-Verticle>{{invokerPackage}}.MainVerticle</Main-Verticle>
|
||||
</manifestEntries>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<artifactSet/>
|
||||
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -51,6 +51,7 @@ org.openapitools.codegen.languages.JavaPKMSTServerCodegen
|
||||
org.openapitools.codegen.languages.JavaPlayFrameworkCodegen
|
||||
org.openapitools.codegen.languages.JavaUndertowServerCodegen
|
||||
org.openapitools.codegen.languages.JavaVertXServerCodegen
|
||||
org.openapitools.codegen.languages.JavaVertXWebServerCodegen
|
||||
org.openapitools.codegen.languages.JavaCXFServerCodegen
|
||||
org.openapitools.codegen.languages.JavaCXFExtServerCodegen
|
||||
org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen
|
||||
|
1
pom.xml
1
pom.xml
@ -1167,6 +1167,7 @@
|
||||
<module>samples/server/petstore/scala-lagom-server</module>
|
||||
<module>samples/server/petstore/scala-play-server</module>
|
||||
<module>samples/server/petstore/scalatra</module>
|
||||
<module>samples/server/petstore/java-vertx-web/rx</module>
|
||||
<module>samples/server/petstore/scala-finch</module>
|
||||
<module>samples/server/petstore/kotlin/vertx</module>
|
||||
<module>samples/server/petstore/kotlin-springboot</module>
|
||||
|
@ -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
|
@ -0,0 +1 @@
|
||||
4.2.0-SNAPSHOT
|
11
samples/server/petstore/java-vertx-web/rx/README.md
Normal file
11
samples/server/petstore/java-vertx-web/rx/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
## Getting Started
|
||||
|
||||
This document assumes you have maven available.
|
||||
|
||||
To build the project using maven, run:
|
||||
```bash
|
||||
mvn package && java -jar target/target/java-vertx-web-rx-server-1.0.0-SNAPSHOT-fat.jar
|
||||
```
|
||||
|
||||
If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:8080/)
|
102
samples/server/petstore/java-vertx-web/rx/pom.xml
Normal file
102
samples/server/petstore/java-vertx-web/rx/pom.xml
Normal file
@ -0,0 +1,102 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>java-vertx-web-rx-server</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>OpenAPI Petstore</name>
|
||||
|
||||
<properties>
|
||||
<vertx.version>3.6.3</vertx.version>
|
||||
<slf4j.version>1.7.26</slf4j.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-web</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-web-api-contract</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-rx-java2</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.reactivex.rxjava2</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<manifestEntries>
|
||||
<Main-Class>io.vertx.core.Starter</Main-Class>
|
||||
<Main-Verticle>org.openapitools.vertxweb.server.MainVerticle</Main-Verticle>
|
||||
</manifestEntries>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<artifactSet/>
|
||||
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,24 @@
|
||||
package org.openapitools.vertxweb.server;
|
||||
|
||||
public class ApiException extends RuntimeException {
|
||||
private final String message;
|
||||
private Integer statusCode;
|
||||
|
||||
public ApiException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ApiException setStatusCode(Integer statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package org.openapitools.vertxweb.server;
|
||||
|
||||
public class ApiResponse<T> {
|
||||
private final T data;
|
||||
private Integer statusCode;
|
||||
|
||||
public ApiResponse(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ApiResponse() {
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ApiResponse<T> setStatusCode(Integer statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
package org.openapitools.vertxweb.server;
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.http.HttpServerOptions;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import io.vertx.ext.web.api.contract.RouterFactoryOptions;
|
||||
import io.vertx.reactivex.core.AbstractVerticle;
|
||||
import io.vertx.reactivex.ext.web.api.contract.openapi3.OpenAPI3RouterFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.openapitools.vertxweb.server.api.PetApiHandler;
|
||||
import org.openapitools.vertxweb.server.api.StoreApiHandler;
|
||||
import org.openapitools.vertxweb.server.api.UserApiHandler;
|
||||
|
||||
public class HttpServerVerticle extends AbstractVerticle {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpServerVerticle.class);
|
||||
|
||||
private static String specFile = "src/main/resources/openapi.yaml";
|
||||
|
||||
private Map<String, Handler<RoutingContext>> operationHandlers = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void start(Future<Void> fut) {
|
||||
|
||||
new PetApiHandler(operationHandlers);
|
||||
new StoreApiHandler(operationHandlers);
|
||||
new UserApiHandler(operationHandlers);
|
||||
|
||||
OpenAPI3RouterFactory.rxCreate(vertx, specFile)
|
||||
.doOnSuccess(factory -> {
|
||||
factory.setOptions(new RouterFactoryOptions()
|
||||
.setRequireSecurityHandlers(false)
|
||||
.setMountNotImplementedHandler(false));
|
||||
factory.setValidationFailureHandler(this::validationFailureHandler);
|
||||
operationHandlers.forEach(factory.getDelegate()::addHandlerByOperationId);
|
||||
})
|
||||
.map(OpenAPI3RouterFactory::getRouter)
|
||||
.doOnSuccess(router -> router.route().last().handler(this::methodNotFoundHandler))
|
||||
.map(router ->
|
||||
vertx.createHttpServer(new HttpServerOptions()
|
||||
.setPort(8080)
|
||||
.setHost("localhost"))
|
||||
.requestHandler(router)
|
||||
.listen()
|
||||
)
|
||||
.subscribe( httpServer -> {
|
||||
logger.info("Http verticle deployed successful");
|
||||
fut.complete();
|
||||
}, error -> {
|
||||
logger.info("Http verticle failed to deployed", error);
|
||||
fut.fail(error.getCause());
|
||||
});
|
||||
}
|
||||
|
||||
private void validationFailureHandler(io.vertx.reactivex.ext.web.RoutingContext rc) {
|
||||
rc.response().setStatusCode(400)
|
||||
.end("Bad Request : " + rc.failure().getMessage());
|
||||
}
|
||||
|
||||
private void methodNotFoundHandler(io.vertx.reactivex.ext.web.RoutingContext rc) {
|
||||
rc.response().setStatusCode(404)
|
||||
.end("Method '" + rc.request().path() + "' Not Found");
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.openapitools.vertxweb.server;
|
||||
|
||||
import io.vertx.core.DeploymentOptions;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.reactivex.core.AbstractVerticle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MainVerticle extends AbstractVerticle {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MainVerticle.class);
|
||||
|
||||
@Override
|
||||
public void start(Future<Void> future) {
|
||||
|
||||
DeploymentOptions options = new DeploymentOptions();
|
||||
options.setInstances(Runtime.getRuntime().availableProcessors());
|
||||
|
||||
vertx.deployVerticle(HttpServerVerticle.class.getName(), options, res -> {
|
||||
if (!res.succeeded()) {
|
||||
logger.error("Deployment fail reason: ", res.cause());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,88 @@
|
||||
package org.openapitools.vertxweb.server;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.Json;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class ParameterCast {
|
||||
|
||||
public static Boolean toBoolean(String str) {
|
||||
if (str != null) {
|
||||
return Boolean.parseBoolean(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static UUID toUUID(String str) {
|
||||
if (str != null) {
|
||||
return UUID.fromString(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer toInteger(String str) {
|
||||
if (str != null) {
|
||||
return Integer.parseInt(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Long toLong(String str) {
|
||||
if (str != null) {
|
||||
return Long.parseLong(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Double toDouble(String str) {
|
||||
if (str != null){
|
||||
return Double.parseDouble(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Float toFloat(String str) {
|
||||
if (str != null){
|
||||
return Float.parseFloat(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static OffsetDateTime toOffsetDateTime(String str) {
|
||||
if (str != null) {
|
||||
return OffsetDateTime.parse(str,
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String toString(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
public static <T> T toObject(String str) {
|
||||
if (str != null) {
|
||||
return Json.decodeValue(str, new TypeReference<T>(){});
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T toObject(String str, Class<T> classz) {
|
||||
if (str != null) {
|
||||
return Json.decodeValue(str, classz);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
import org.openapitools.vertxweb.server.model.ModelApiResponse;
|
||||
import org.openapitools.vertxweb.server.model.Pet;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PetApi {
|
||||
Single<ApiResponse<Void>> addPet(Pet pet);
|
||||
Single<ApiResponse<Void>> deletePet(Long petId,String apiKey);
|
||||
Single<ApiResponse<List<Pet>>> findPetsByStatus(List<String> status);
|
||||
Single<ApiResponse<List<Pet>>> findPetsByTags(List<String> tags);
|
||||
Single<ApiResponse<Pet>> getPetById(Long petId);
|
||||
Single<ApiResponse<Void>> updatePet(Pet pet);
|
||||
Single<ApiResponse<Void>> updatePetWithForm(Long petId,String name,String status);
|
||||
Single<ApiResponse<ModelApiResponse>> uploadFile(Long petId,String additionalMetadata,FileUpload file);
|
||||
}
|
@ -0,0 +1,242 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
import org.openapitools.vertxweb.server.model.ModelApiResponse;
|
||||
import org.openapitools.vertxweb.server.model.Pet;
|
||||
|
||||
import org.openapitools.vertxweb.server.ParameterCast;
|
||||
import org.openapitools.vertxweb.server.ApiException;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.http.HttpServerResponse;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PetApiHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PetApiHandler.class);
|
||||
private PetApi apiImpl = new PetApiImpl();
|
||||
|
||||
public PetApiHandler(Map<String, Handler<RoutingContext>> operationHandlers) {
|
||||
operationHandlers.put("addPet", this::addPet);
|
||||
operationHandlers.put("deletePet", this::deletePet);
|
||||
operationHandlers.put("findPetsByStatus", this::findPetsByStatus);
|
||||
operationHandlers.put("findPetsByTags", this::findPetsByTags);
|
||||
operationHandlers.put("getPetById", this::getPetById);
|
||||
operationHandlers.put("updatePet", this::updatePet);
|
||||
operationHandlers.put("updatePetWithForm", this::updatePetWithForm);
|
||||
operationHandlers.put("uploadFile", this::uploadFile);
|
||||
}
|
||||
|
||||
private void addPet(RoutingContext routingContext) {
|
||||
logger.info("addPet()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
Pet pet = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<Pet>(){});
|
||||
logger.info("Parameter pet is {}", pet);
|
||||
return apiImpl.addPet(pet);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void deletePet(RoutingContext routingContext) {
|
||||
logger.info("deletePet()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
Long petId = ParameterCast.toLong(routingContext.pathParams().get("petId"));
|
||||
String apiKey = ParameterCast.toString(routingContext.request().getHeader("api_key"));
|
||||
logger.info("Parameter petId is {}", petId);
|
||||
logger.info("Parameter apiKey is {}", apiKey);
|
||||
return apiImpl.deletePet(petId, apiKey);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void findPetsByStatus(RoutingContext routingContext) {
|
||||
logger.info("findPetsByStatus()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
List<String> status = routingContext.request().params().getAll("status");
|
||||
logger.info("Parameter status is {}", status);
|
||||
return apiImpl.findPetsByStatus(status);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void findPetsByTags(RoutingContext routingContext) {
|
||||
logger.info("findPetsByTags()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
List<String> tags = routingContext.request().params().getAll("tags");
|
||||
logger.info("Parameter tags is {}", tags);
|
||||
return apiImpl.findPetsByTags(tags);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void getPetById(RoutingContext routingContext) {
|
||||
logger.info("getPetById()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
Long petId = ParameterCast.toLong(routingContext.pathParams().get("petId"));
|
||||
logger.info("Parameter petId is {}", petId);
|
||||
return apiImpl.getPetById(petId);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void updatePet(RoutingContext routingContext) {
|
||||
logger.info("updatePet()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
Pet pet = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<Pet>(){});
|
||||
logger.info("Parameter pet is {}", pet);
|
||||
return apiImpl.updatePet(pet);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void updatePetWithForm(RoutingContext routingContext) {
|
||||
logger.info("updatePetWithForm()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
Long petId = ParameterCast.toLong(routingContext.pathParams().get("petId"));
|
||||
String name = ParameterCast.toString(routingContext.request().getFormAttribute("name"));
|
||||
String status = ParameterCast.toString(routingContext.request().getFormAttribute("status"));
|
||||
logger.info("Parameter petId is {}", petId);
|
||||
logger.info("Parameter name is {}", name);
|
||||
logger.info("Parameter status is {}", status);
|
||||
return apiImpl.updatePetWithForm(petId, name, status);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void uploadFile(RoutingContext routingContext) {
|
||||
logger.info("uploadFile()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
Long petId = ParameterCast.toLong(routingContext.pathParams().get("petId"));
|
||||
String additionalMetadata = ParameterCast.toString(routingContext.request().getFormAttribute("additionalMetadata"));
|
||||
FileUpload file = routingContext.fileUploads().iterator().next();
|
||||
logger.info("Parameter petId is {}", petId);
|
||||
logger.info("Parameter additionalMetadata is {}", additionalMetadata);
|
||||
logger.info("Parameter file is {}", file);
|
||||
return apiImpl.uploadFile(petId, additionalMetadata, file);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
import org.openapitools.vertxweb.server.model.ModelApiResponse;
|
||||
import org.openapitools.vertxweb.server.model.Pet;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
import org.openapitools.vertxweb.server.ApiException;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Implement this class
|
||||
|
||||
public class PetApiImpl implements PetApi {
|
||||
public Single<ApiResponse<Void>> addPet(Pet pet) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> deletePet(Long petId,String apiKey) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<List<Pet>>> findPetsByStatus(List<String> status) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<List<Pet>>> findPetsByTags(List<String> tags) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Pet>> getPetById(Long petId) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> updatePet(Pet pet) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> updatePetWithForm(Long petId,String name,String status) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<ModelApiResponse>> uploadFile(Long petId,String additionalMetadata,FileUpload file) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.Order;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface StoreApi {
|
||||
Single<ApiResponse<Void>> deleteOrder(String orderId);
|
||||
Single<ApiResponse<Map<String, Integer>>> getInventory();
|
||||
Single<ApiResponse<Order>> getOrderById(Long orderId);
|
||||
Single<ApiResponse<Order>> placeOrder(Order order);
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.Order;
|
||||
|
||||
import org.openapitools.vertxweb.server.ParameterCast;
|
||||
import org.openapitools.vertxweb.server.ApiException;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.http.HttpServerResponse;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StoreApiHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StoreApiHandler.class);
|
||||
private StoreApi apiImpl = new StoreApiImpl();
|
||||
|
||||
public StoreApiHandler(Map<String, Handler<RoutingContext>> operationHandlers) {
|
||||
operationHandlers.put("deleteOrder", this::deleteOrder);
|
||||
operationHandlers.put("getInventory", this::getInventory);
|
||||
operationHandlers.put("getOrderById", this::getOrderById);
|
||||
operationHandlers.put("placeOrder", this::placeOrder);
|
||||
}
|
||||
|
||||
private void deleteOrder(RoutingContext routingContext) {
|
||||
logger.info("deleteOrder()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String orderId = ParameterCast.toString(routingContext.pathParams().get("orderId"));
|
||||
logger.info("Parameter orderId is {}", orderId);
|
||||
return apiImpl.deleteOrder(orderId);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void getInventory(RoutingContext routingContext) {
|
||||
logger.info("getInventory()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
return apiImpl.getInventory();
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void getOrderById(RoutingContext routingContext) {
|
||||
logger.info("getOrderById()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
Long orderId = ParameterCast.toLong(routingContext.pathParams().get("orderId"));
|
||||
logger.info("Parameter orderId is {}", orderId);
|
||||
return apiImpl.getOrderById(orderId);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void placeOrder(RoutingContext routingContext) {
|
||||
logger.info("placeOrder()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
Order order = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<Order>(){});
|
||||
logger.info("Parameter order is {}", order);
|
||||
return apiImpl.placeOrder(order);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.Order;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
import org.openapitools.vertxweb.server.ApiException;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Implement this class
|
||||
|
||||
public class StoreApiImpl implements StoreApi {
|
||||
public Single<ApiResponse<Void>> deleteOrder(String orderId) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Map<String, Integer>>> getInventory() {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Order>> getOrderById(Long orderId) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Order>> placeOrder(Order order) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.User;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserApi {
|
||||
Single<ApiResponse<Void>> createUser(User user);
|
||||
Single<ApiResponse<Void>> createUsersWithArrayInput(List<User> user);
|
||||
Single<ApiResponse<Void>> createUsersWithListInput(List<User> user);
|
||||
Single<ApiResponse<Void>> deleteUser(String username);
|
||||
Single<ApiResponse<User>> getUserByName(String username);
|
||||
Single<ApiResponse<String>> loginUser(String username,String password);
|
||||
Single<ApiResponse<Void>> logoutUser();
|
||||
Single<ApiResponse<Void>> updateUser(String username,User user);
|
||||
}
|
@ -0,0 +1,234 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.User;
|
||||
|
||||
import org.openapitools.vertxweb.server.ParameterCast;
|
||||
import org.openapitools.vertxweb.server.ApiException;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.http.HttpServerResponse;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserApiHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserApiHandler.class);
|
||||
private UserApi apiImpl = new UserApiImpl();
|
||||
|
||||
public UserApiHandler(Map<String, Handler<RoutingContext>> operationHandlers) {
|
||||
operationHandlers.put("createUser", this::createUser);
|
||||
operationHandlers.put("createUsersWithArrayInput", this::createUsersWithArrayInput);
|
||||
operationHandlers.put("createUsersWithListInput", this::createUsersWithListInput);
|
||||
operationHandlers.put("deleteUser", this::deleteUser);
|
||||
operationHandlers.put("getUserByName", this::getUserByName);
|
||||
operationHandlers.put("loginUser", this::loginUser);
|
||||
operationHandlers.put("logoutUser", this::logoutUser);
|
||||
operationHandlers.put("updateUser", this::updateUser);
|
||||
}
|
||||
|
||||
private void createUser(RoutingContext routingContext) {
|
||||
logger.info("createUser()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
User user = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<User>(){});
|
||||
logger.info("Parameter user is {}", user);
|
||||
return apiImpl.createUser(user);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void createUsersWithArrayInput(RoutingContext routingContext) {
|
||||
logger.info("createUsersWithArrayInput()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
List<User> user = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<List<User>>(){});
|
||||
logger.info("Parameter user is {}", user);
|
||||
return apiImpl.createUsersWithArrayInput(user);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void createUsersWithListInput(RoutingContext routingContext) {
|
||||
logger.info("createUsersWithListInput()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
List<User> user = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<List<User>>(){});
|
||||
logger.info("Parameter user is {}", user);
|
||||
return apiImpl.createUsersWithListInput(user);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void deleteUser(RoutingContext routingContext) {
|
||||
logger.info("deleteUser()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String username = ParameterCast.toString(routingContext.pathParams().get("username"));
|
||||
logger.info("Parameter username is {}", username);
|
||||
return apiImpl.deleteUser(username);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void getUserByName(RoutingContext routingContext) {
|
||||
logger.info("getUserByName()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String username = ParameterCast.toString(routingContext.pathParams().get("username"));
|
||||
logger.info("Parameter username is {}", username);
|
||||
return apiImpl.getUserByName(username);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void loginUser(RoutingContext routingContext) {
|
||||
logger.info("loginUser()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String username = ParameterCast.toString(routingContext.queryParams().get("username"));
|
||||
String password = ParameterCast.toString(routingContext.queryParams().get("password"));
|
||||
logger.info("Parameter username is {}", username);
|
||||
logger.info("Parameter password is {}", password);
|
||||
return apiImpl.loginUser(username, password);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void logoutUser(RoutingContext routingContext) {
|
||||
logger.info("logoutUser()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
return apiImpl.logoutUser();
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
|
||||
private void updateUser(RoutingContext routingContext) {
|
||||
logger.info("updateUser()");
|
||||
HttpServerResponse response = routingContext.response();
|
||||
|
||||
Single.defer( () -> {
|
||||
String username = ParameterCast.toString(routingContext.pathParams().get("username"));
|
||||
String jsonString = routingContext.getBodyAsString();
|
||||
User user = jsonString == null ? null : Json.decodeValue(jsonString, new TypeReference<User>(){});
|
||||
logger.info("Parameter username is {}", username);
|
||||
logger.info("Parameter user is {}", user);
|
||||
return apiImpl.updateUser(username, user);
|
||||
})
|
||||
.subscribe(
|
||||
apiResponse -> {
|
||||
response.setStatusCode(apiResponse.getStatusCode())
|
||||
.end(Json.encodePrettily(apiResponse.getData()));
|
||||
}, error -> {
|
||||
if (error instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) error;
|
||||
response.setStatusCode(apiException.getStatusCode()).end(apiException.getMessage());
|
||||
} else {
|
||||
response.setStatusCode(500).end(error.getMessage());
|
||||
}
|
||||
}).dispose();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.User;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
import org.openapitools.vertxweb.server.ApiException;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Implement this class
|
||||
|
||||
public class UserApiImpl implements UserApi {
|
||||
public Single<ApiResponse<Void>> createUser(User user) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> createUsersWithArrayInput(List<User> user) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> createUsersWithListInput(List<User> user) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> deleteUser(String username) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<User>> getUserByName(String username) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<String>> loginUser(String username,String password) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> logoutUser() {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
public Single<ApiResponse<Void>> updateUser(String username,User user) {
|
||||
return Single.error(new ApiException("Not Implemented").setStatusCode(501));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Category {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Category () {
|
||||
|
||||
}
|
||||
|
||||
public Category (Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(id, category.id) &&
|
||||
Objects.equals(name, category.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class InlineObject {
|
||||
|
||||
private String name;
|
||||
private String status;
|
||||
|
||||
public InlineObject () {
|
||||
|
||||
}
|
||||
|
||||
public InlineObject (String name, String status) {
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
InlineObject inlineObject = (InlineObject) o;
|
||||
return Objects.equals(name, inlineObject.name) &&
|
||||
Objects.equals(status, inlineObject.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class InlineObject {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class InlineObject1 {
|
||||
|
||||
private String additionalMetadata;
|
||||
private FileUpload file;
|
||||
|
||||
public InlineObject1 () {
|
||||
|
||||
}
|
||||
|
||||
public InlineObject1 (String additionalMetadata, FileUpload file) {
|
||||
this.additionalMetadata = additionalMetadata;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("additionalMetadata")
|
||||
public String getAdditionalMetadata() {
|
||||
return additionalMetadata;
|
||||
}
|
||||
public void setAdditionalMetadata(String additionalMetadata) {
|
||||
this.additionalMetadata = additionalMetadata;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("file")
|
||||
public FileUpload getFile() {
|
||||
return file;
|
||||
}
|
||||
public void setFile(FileUpload file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
InlineObject1 inlineObject1 = (InlineObject1) o;
|
||||
return Objects.equals(additionalMetadata, inlineObject1.additionalMetadata) &&
|
||||
Objects.equals(file, inlineObject1.file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(additionalMetadata, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class InlineObject1 {\n");
|
||||
|
||||
sb.append(" additionalMetadata: ").append(toIndentedString(additionalMetadata)).append("\n");
|
||||
sb.append(" file: ").append(toIndentedString(file)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ModelApiResponse {
|
||||
|
||||
private Integer code;
|
||||
private String type;
|
||||
private String message;
|
||||
|
||||
public ModelApiResponse () {
|
||||
|
||||
}
|
||||
|
||||
public ModelApiResponse (Integer code, String type, String message) {
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("code")
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("message")
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
||||
return Objects.equals(code, _apiResponse.code) &&
|
||||
Objects.equals(type, _apiResponse.type) &&
|
||||
Objects.equals(message, _apiResponse.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, type, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelApiResponse {\n");
|
||||
|
||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Order {
|
||||
|
||||
private Long id;
|
||||
private Long petId;
|
||||
private Integer quantity;
|
||||
private OffsetDateTime shipDate;
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
APPROVED("approved"),
|
||||
DELIVERED("delivered");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
private Boolean complete = false;
|
||||
|
||||
public Order () {
|
||||
|
||||
}
|
||||
|
||||
public Order (Long id, Long petId, Integer quantity, OffsetDateTime shipDate, StatusEnum status, Boolean complete) {
|
||||
this.id = id;
|
||||
this.petId = petId;
|
||||
this.quantity = quantity;
|
||||
this.shipDate = shipDate;
|
||||
this.status = status;
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("petId")
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("quantity")
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("shipDate")
|
||||
public OffsetDateTime getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
public void setShipDate(OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("complete")
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(id, order.id) &&
|
||||
Objects.equals(petId, order.petId) &&
|
||||
Objects.equals(quantity, order.quantity) &&
|
||||
Objects.equals(shipDate, order.shipDate) &&
|
||||
Objects.equals(status, order.status) &&
|
||||
Objects.equals(complete, order.complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.vertxweb.server.model.Category;
|
||||
import org.openapitools.vertxweb.server.model.Tag;
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Pet {
|
||||
|
||||
private Long id;
|
||||
private Category category;
|
||||
private String name;
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
PENDING("pending"),
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
|
||||
public Pet () {
|
||||
|
||||
}
|
||||
|
||||
public Pet (Long id, Category category, String name, List<String> photoUrls, List<Tag> tags, StatusEnum status) {
|
||||
this.id = id;
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.photoUrls = photoUrls;
|
||||
this.tags = tags;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("category")
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("photoUrls")
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("tags")
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(id, pet.id) &&
|
||||
Objects.equals(category, pet.category) &&
|
||||
Objects.equals(name, pet.name) &&
|
||||
Objects.equals(photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(tags, pet.tags) &&
|
||||
Objects.equals(status, pet.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Tag {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Tag () {
|
||||
|
||||
}
|
||||
|
||||
public Tag (Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(id, tag.id) &&
|
||||
Objects.equals(name, tag.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class User {
|
||||
|
||||
private Long id;
|
||||
private String username;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String password;
|
||||
private String phone;
|
||||
private Integer userStatus;
|
||||
|
||||
public User () {
|
||||
|
||||
}
|
||||
|
||||
public User (Long id, String username, String firstName, String lastName, String email, String password, String phone, Integer userStatus) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.phone = phone;
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("username")
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("firstName")
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("lastName")
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("email")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("password")
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("phone")
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("userStatus")
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(username, user.username) &&
|
||||
Objects.equals(firstName, user.firstName) &&
|
||||
Objects.equals(lastName, user.lastName) &&
|
||||
Objects.equals(email, user.email) &&
|
||||
Objects.equals(password, user.password) &&
|
||||
Objects.equals(phone, user.phone) &&
|
||||
Objects.equals(userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,837 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: This is a sample server Petstore server. For this sample, you can use
|
||||
the api key `special-key` to test the authorization filters.
|
||||
license:
|
||||
name: Apache-2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
title: OpenAPI Petstore
|
||||
version: 1.0.0
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: http://swagger.io
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/v2
|
||||
tags:
|
||||
- description: Everything about your Pets
|
||||
name: pet
|
||||
- description: Access to Petstore orders
|
||||
name: store
|
||||
- description: Operations about user
|
||||
name: user
|
||||
paths:
|
||||
/pet:
|
||||
post:
|
||||
operationId: addPet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
405:
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Add a new pet to the store
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
put:
|
||||
operationId: updatePet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Pet not found
|
||||
405:
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Update an existing pet
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- description: Status values that need to be considered for filter
|
||||
explode: false
|
||||
in: query
|
||||
name: status
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
default: available
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
400:
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by status
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
/pet/findByTags:
|
||||
get:
|
||||
deprecated: true
|
||||
description: Multiple tags can be provided with comma separated strings. Use
|
||||
tag1, tag2, tag3 for testing.
|
||||
operationId: findPetsByTags
|
||||
parameters:
|
||||
- description: Tags to filter by
|
||||
explode: false
|
||||
in: query
|
||||
name: tags
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
400:
|
||||
description: Invalid tag value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by tags
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
/pet/{petId}:
|
||||
delete:
|
||||
operationId: deletePet
|
||||
parameters:
|
||||
- explode: false
|
||||
in: header
|
||||
name: api_key
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
- description: Pet id to delete
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
400:
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Deletes a pet
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
get:
|
||||
description: Returns a single pet
|
||||
operationId: getPetById
|
||||
parameters:
|
||||
- description: ID of pet to return
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Find pet by ID
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
post:
|
||||
operationId: updatePetWithForm
|
||||
parameters:
|
||||
- description: ID of pet that needs to be updated
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/inline_object'
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
properties:
|
||||
name:
|
||||
description: Updated name of the pet
|
||||
type: string
|
||||
status:
|
||||
description: Updated status of the pet
|
||||
type: string
|
||||
type: object
|
||||
responses:
|
||||
405:
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Updates a pet in the store with form data
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: application/x-www-form-urlencoded
|
||||
x-accepts: application/json
|
||||
/pet/{petId}/uploadImage:
|
||||
post:
|
||||
operationId: uploadFile
|
||||
parameters:
|
||||
- description: ID of pet to update
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/inline_object_1'
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
properties:
|
||||
additionalMetadata:
|
||||
description: Additional data to pass to server
|
||||
type: string
|
||||
file:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
type: object
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
description: successful operation
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: uploads an image
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: multipart/form-data
|
||||
x-accepts: application/json
|
||||
/store/inventory:
|
||||
get:
|
||||
description: Returns a map of status codes to quantities
|
||||
operationId: getInventory
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
additionalProperties:
|
||||
format: int32
|
||||
type: integer
|
||||
type: object
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Returns pet inventories by status
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
/store/order:
|
||||
post:
|
||||
operationId: placeOrder
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: order placed for purchasing the pet
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
400:
|
||||
description: Invalid Order
|
||||
summary: Place an order for a pet
|
||||
tags:
|
||||
- store
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/store/order/{orderId}:
|
||||
delete:
|
||||
description: For valid response try integer IDs with value < 1000. Anything
|
||||
above 1000 or nonintegers will generate API errors
|
||||
operationId: deleteOrder
|
||||
parameters:
|
||||
- description: ID of the order that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Order not found
|
||||
summary: Delete purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
get:
|
||||
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
||||
values will generated exceptions
|
||||
operationId: getOrderById
|
||||
parameters:
|
||||
- description: ID of pet that needs to be fetched
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Order not found
|
||||
summary: Find purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
/user:
|
||||
post:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Created user object
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- auth_cookie: []
|
||||
summary: Create user
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/user/createWithArray:
|
||||
post:
|
||||
operationId: createUsersWithArrayInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- auth_cookie: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/user/createWithList:
|
||||
post:
|
||||
operationId: createUsersWithListInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- auth_cookie: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/user/login:
|
||||
get:
|
||||
operationId: loginUser
|
||||
parameters:
|
||||
- description: The user name for login
|
||||
explode: true
|
||||
in: query
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
||||
type: string
|
||||
style: form
|
||||
- description: The password for login in clear text
|
||||
explode: true
|
||||
in: query
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: form
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: string
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: successful operation
|
||||
headers:
|
||||
Set-Cookie:
|
||||
description: Cookie authentication key for use with the `auth_cookie`
|
||||
apiKey authentication.
|
||||
explode: false
|
||||
schema:
|
||||
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
||||
type: string
|
||||
style: simple
|
||||
X-Rate-Limit:
|
||||
description: calls per hour allowed by the user
|
||||
explode: false
|
||||
schema:
|
||||
format: int32
|
||||
type: integer
|
||||
style: simple
|
||||
X-Expires-After:
|
||||
description: date in UTC when toekn expires
|
||||
explode: false
|
||||
schema:
|
||||
format: date-time
|
||||
type: string
|
||||
style: simple
|
||||
400:
|
||||
description: Invalid username/password supplied
|
||||
summary: Logs user into the system
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
/user/logout:
|
||||
get:
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- auth_cookie: []
|
||||
summary: Logs out current logged in user session
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
/user/{username}:
|
||||
delete:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteUser
|
||||
parameters:
|
||||
- description: The name that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
400:
|
||||
description: Invalid username supplied
|
||||
404:
|
||||
description: User not found
|
||||
security:
|
||||
- auth_cookie: []
|
||||
summary: Delete user
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
get:
|
||||
operationId: getUserByName
|
||||
parameters:
|
||||
- description: The name that needs to be fetched. Use user1 for testing.
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: successful operation
|
||||
400:
|
||||
description: Invalid username supplied
|
||||
404:
|
||||
description: User not found
|
||||
summary: Get user by user name
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
put:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
parameters:
|
||||
- description: name that need to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Updated user object
|
||||
required: true
|
||||
responses:
|
||||
400:
|
||||
description: Invalid user supplied
|
||||
404:
|
||||
description: User not found
|
||||
security:
|
||||
- auth_cookie: []
|
||||
summary: Updated user
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
components:
|
||||
requestBodies:
|
||||
UserArray:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
type: array
|
||||
description: List of user object
|
||||
required: true
|
||||
Pet:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
required: true
|
||||
inline_object:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_object'
|
||||
inline_object_1:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_object_1'
|
||||
schemas:
|
||||
Order:
|
||||
description: An order for a pets from the pet store
|
||||
example:
|
||||
petId: 6
|
||||
quantity: 1
|
||||
id: 0
|
||||
shipDate: 2000-01-23T04:56:07.000+00:00
|
||||
complete: false
|
||||
status: placed
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
petId:
|
||||
format: int64
|
||||
type: integer
|
||||
quantity:
|
||||
format: int32
|
||||
type: integer
|
||||
shipDate:
|
||||
format: date-time
|
||||
type: string
|
||||
status:
|
||||
description: Order Status
|
||||
enum:
|
||||
- placed
|
||||
- approved
|
||||
- delivered
|
||||
type: string
|
||||
complete:
|
||||
default: false
|
||||
type: boolean
|
||||
title: Pet Order
|
||||
type: object
|
||||
xml:
|
||||
name: Order
|
||||
Category:
|
||||
description: A category for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 6
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
||||
type: string
|
||||
title: Pet category
|
||||
type: object
|
||||
xml:
|
||||
name: Category
|
||||
User:
|
||||
description: A User who is purchasing from the pet store
|
||||
example:
|
||||
firstName: firstName
|
||||
lastName: lastName
|
||||
password: password
|
||||
userStatus: 6
|
||||
phone: phone
|
||||
id: 0
|
||||
email: email
|
||||
username: username
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
username:
|
||||
type: string
|
||||
firstName:
|
||||
type: string
|
||||
lastName:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
userStatus:
|
||||
description: User Status
|
||||
format: int32
|
||||
type: integer
|
||||
title: a User
|
||||
type: object
|
||||
xml:
|
||||
name: User
|
||||
Tag:
|
||||
description: A tag for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 1
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
title: Pet Tag
|
||||
type: object
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
description: A pet for sale in the pet store
|
||||
example:
|
||||
photoUrls:
|
||||
- photoUrls
|
||||
- photoUrls
|
||||
name: doggie
|
||||
id: 0
|
||||
category:
|
||||
name: name
|
||||
id: 6
|
||||
tags:
|
||||
- name: name
|
||||
id: 1
|
||||
- name: name
|
||||
id: 1
|
||||
status: available
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
category:
|
||||
$ref: '#/components/schemas/Category'
|
||||
name:
|
||||
example: doggie
|
||||
type: string
|
||||
photoUrls:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
xml:
|
||||
name: photoUrl
|
||||
wrapped: true
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/components/schemas/Tag'
|
||||
type: array
|
||||
xml:
|
||||
name: tag
|
||||
wrapped: true
|
||||
status:
|
||||
description: pet status in the store
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- photoUrls
|
||||
title: a Pet
|
||||
type: object
|
||||
xml:
|
||||
name: Pet
|
||||
ApiResponse:
|
||||
description: Describes the result of uploading an image resource
|
||||
example:
|
||||
code: 0
|
||||
type: type
|
||||
message: message
|
||||
properties:
|
||||
code:
|
||||
format: int32
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
title: An uploaded response
|
||||
type: object
|
||||
inline_object:
|
||||
properties:
|
||||
name:
|
||||
description: Updated name of the pet
|
||||
type: string
|
||||
status:
|
||||
description: Updated status of the pet
|
||||
type: string
|
||||
type: object
|
||||
inline_object_1:
|
||||
properties:
|
||||
additionalMetadata:
|
||||
description: Additional data to pass to server
|
||||
type: string
|
||||
file:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
type: object
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||
scopes:
|
||||
write:pets: modify pets in your account
|
||||
read:pets: read your pets
|
||||
type: oauth2
|
||||
api_key:
|
||||
in: header
|
||||
name: api_key
|
||||
type: apiKey
|
||||
auth_cookie:
|
||||
in: cookie
|
||||
name: AUTH_KEY
|
||||
type: apiKey
|
Loading…
x
Reference in New Issue
Block a user