forked from loafle/openapi-generator-original
Merge branch 'master' of https://github.com/swagger-api/swagger-codegen
This commit is contained in:
106
.travis.yml
106
.travis.yml
@@ -1,33 +1,32 @@
|
||||
sudo: required
|
||||
language: objective-c
|
||||
osx_image: xcode8.2
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
- $HOME/.ivy2
|
||||
- $HOME/.gradle/caches/
|
||||
- $HOME/.gradle/wrapper/
|
||||
- $HOME/.stack
|
||||
- $HOME/samples/client/petstore/php/SwaggerClient-php/vendor
|
||||
- $HOME/samples/client/petstore/ruby/venodr/bundle
|
||||
- $HOME/samples/client/petstore/python/.venv/
|
||||
# - $HOME/samples/client/petstore/typescript-node/npm/node_modules
|
||||
# - $HOME/samples/client/petstore/typescript-node/npm/typings/
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/tests/default/typings
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/builds/default/node_modules
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/builds/default/typings
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/node_modules
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/typings
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/builds/with-npm-version/node_modules
|
||||
# - $HOME/samples/client/petstore/typescript-fetch/npm/with-npm-version/typings
|
||||
# - $HOME/samples/client/petstore/typescript-angularjs/node_modules
|
||||
# - $HOME/samples/client/petstore/typescript-angularjs/typings
|
||||
- $HOME/.cocoapods/repos/master
|
||||
timeout: 1000
|
||||
# note: docker is not yet supported in iOS build
|
||||
#services:
|
||||
# - docker
|
||||
- $HOME/samples/client/petstore/typescript-node/npm/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-node/npm/typings/
|
||||
- $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-fetch/tests/default/typings
|
||||
- $HOME/samples/client/petstore/typescript-fetch/builds/default/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-fetch/builds/default/typings
|
||||
- $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/typings
|
||||
- $HOME/samples/client/petstore/typescript-fetch/builds/with-npm-version/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-fetch/npm/with-npm-version/typings
|
||||
- $HOME/samples/client/petstore/typescript-angular/node_modules
|
||||
- $HOME/samples/client/petstore/typescript-angular/typings
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
# comment out the host table change to use the public petstore server
|
||||
addons:
|
||||
@@ -35,60 +34,38 @@ addons:
|
||||
- petstore.swagger.io
|
||||
|
||||
before_install:
|
||||
- export SW=`pwd`
|
||||
- rvm list
|
||||
- rvm use 2.2.5
|
||||
- gem environment
|
||||
- gem install bundler -N --no-ri --no-rdoc
|
||||
- gem install cocoapods -v 1.2.1 -N --no-ri --no-rdoc
|
||||
- gem install xcpretty -N --no-ri --no-rdoc
|
||||
- pod --version
|
||||
# comment out below to avoid errors
|
||||
#- pod repo update
|
||||
- pod setup --silent > /dev/null
|
||||
# required when sudo: required for the Ruby petstore tests
|
||||
- gem install bundler
|
||||
- npm install -g typescript
|
||||
- npm install -g npm
|
||||
- npm config set registry http://registry.npmjs.org/
|
||||
- brew install sbt
|
||||
- brew install leiningen
|
||||
- brew install bats
|
||||
- brew install curl
|
||||
- brew install python3
|
||||
- pip install virtualenv
|
||||
- mkdir -p ~/.local/bin
|
||||
- export PATH=$HOME/.local/bin:$PATH
|
||||
- travis_retry curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
|
||||
# start local petstore server
|
||||
- git clone -b docker --single-branch https://github.com/wing328/swagger-samples
|
||||
- cd swagger-samples/java/java-jersey-jaxrs
|
||||
- sudo mvn jetty:run &
|
||||
- cd $SW
|
||||
# NOTE: iOS build not support docker at the moment
|
||||
- sudo pip install virtualenv
|
||||
# to run petstore server locally via docker
|
||||
#- docker pull swaggerapi/petstore
|
||||
#- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||
#- docker ps -a
|
||||
- docker pull swaggerapi/petstore
|
||||
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||
- docker ps -a
|
||||
# Add bats test framework and cURL for Bash script integration tests
|
||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq bats
|
||||
- sudo apt-get install -qq curl
|
||||
# comment out below as installation failed in travis
|
||||
# Add rebar3 build tool and recent Erlang/OTP for Erlang petstore server tests.
|
||||
# - Travis CI does not support rebar3 [yet](https://github.com/travis-ci/travis-ci/issues/6506#issuecomment-275189490).
|
||||
# - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18).
|
||||
# - . ~/otp/18.2.1/activate && erl -version
|
||||
#- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH"
|
||||
|
||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||
- cat /etc/hosts
|
||||
# show java version
|
||||
- java -version
|
||||
# show brew version
|
||||
- brew --version
|
||||
# show xcpretty version
|
||||
- xcpretty -v
|
||||
# show go version
|
||||
- go version
|
||||
# show stack version
|
||||
- stack --version
|
||||
|
||||
install:
|
||||
# Add Godeps dependencies to GOPATH and PATH
|
||||
- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
|
||||
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
||||
- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
|
||||
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
|
||||
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
|
||||
|
||||
script:
|
||||
# fail fast
|
||||
@@ -100,14 +77,12 @@ script:
|
||||
# fail if generators contain tab '\t'
|
||||
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
|
||||
# run integration tests defined in maven pom.xml
|
||||
- travis_wait mvn -q --batch-mode verify -Psamples
|
||||
### docker-related tasks have been moved to CircleCI
|
||||
- mvn -q --batch-mode verify -Psamples
|
||||
# Below has been moved to CircleCI
|
||||
# docker: build generator image and push to Docker Hub
|
||||
#- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
|
||||
## docker: build cli image and push to Docker Hub
|
||||
#- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi
|
||||
#env:
|
||||
# - DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli
|
||||
|
||||
after_success:
|
||||
# push a snapshot version to maven repo
|
||||
@@ -115,3 +90,6 @@ after_success:
|
||||
mvn clean deploy --settings .travis/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
fi;
|
||||
|
||||
env:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
## Overview
|
||||
This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported:
|
||||
|
||||
- **API clients**: **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Eiffel**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust**, **Scala** (akka, http4s, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
|
||||
- **API clients**: **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust**, **Scala** (akka, http4s, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
|
||||
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust**, **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
|
||||
- **API documentation generators**: **HTML**, **Confluence Wiki**
|
||||
- **Configuration files**: [**Apache2**](https://httpd.apache.org/)
|
||||
@@ -909,6 +909,7 @@ Presentations/Videos/Tutorials/Books
|
||||
- 2017/09/30 - [Swaggerのテンプレートを魔改造した話 #渋谷java](https://www.slideshare.net/int128/swagger-80309224) by [Hidetake Iwata](https://github.com/int128) ([NTT DATA Corporation](http://www.nttdata.com/global/en/))
|
||||
- 2017/10/04 - [Enterprise-friendly Java client for Microsoft Machine Learning Server](https://blogs.msdn.microsoft.com/mlserver/2017/10/04/enterprise-friendly-java-client-for-microsoft-machine-learning-server/) by [Pratik Palnitkar](https://www.linkedin.com/in/pratikpalnitkar/) ([Microsoft](https://www.microsoft.com/))
|
||||
- 2017/10/08 - [Generating a REST Ada client with OpenAPI and Swagger Codegen](https://blog.vacs.fr/vacs/blogs/post.html?post=2017/10/08/Generating-a-REST-Ada-client-with-OpenAPI-and-Swagger-Codegen) by [Stephane Carrez](https://github.com/stcarrez)
|
||||
- 2017/11/08 - [A Beginner's Guide to Code Generation for REST APIs](https://gum.co/swagger_codegen_beginner)(eBook) by [William Cheng](https://twitter.com/wing328)
|
||||
|
||||
# Swagger Codegen Core Team
|
||||
|
||||
@@ -975,6 +976,7 @@ Here is a list of template creators:
|
||||
* Dart: @yissachar
|
||||
* Elixir: @niku
|
||||
* Eiffel: @jvelilla
|
||||
* Erlang: @tsloughter
|
||||
* Groovy: @victorgit
|
||||
* Go: @wing328
|
||||
* Go (rewritten in 2.3.0): @antihax
|
||||
|
||||
31
bin/erlang-petstore-client.sh
Executable file
31
bin/erlang-petstore-client.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
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/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/erlang-client -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l erlang-client -o samples/client/petstore/erlang-client"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
10
bin/windows/erlang-petstore-client.bat
Executable file
10
bin/windows/erlang-petstore-client.bat
Executable file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\erlang-client -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l erlang-client -o samples\client\petstore\erlang-client
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -0,0 +1,393 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.models.parameters.Parameter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
static Logger LOGGER = LoggerFactory.getLogger(ErlangClientCodegen.class);
|
||||
|
||||
protected String packageName = "swagger";
|
||||
protected String packageVersion = "1.0.0";
|
||||
protected String sourceFolder = "src";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "erlang-client";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates an Erlang client library (beta).";
|
||||
}
|
||||
|
||||
public ErlangClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/erlang";
|
||||
modelTemplateFiles.put("model.mustache", ".erl");
|
||||
apiTemplateFiles.put("api.mustache", ".erl");
|
||||
|
||||
embeddedTemplateDir = templateDir = "erlang-client";
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
"after","and","andalso","band","begin","bnot","bor","bsl","bsr","bxor","case",
|
||||
"catch","cond","div","end","fun","if","let","not","of","or","orelse","receive",
|
||||
"rem","try","when","xor"
|
||||
)
|
||||
);
|
||||
|
||||
instantiationTypes.clear();
|
||||
|
||||
typeMapping.clear();
|
||||
typeMapping.put("enum", "binary()");
|
||||
typeMapping.put("date", "calendar:date()");
|
||||
typeMapping.put("datetime", "calendar:datetime()");
|
||||
typeMapping.put("date-time", "calendar:datetime()");
|
||||
typeMapping.put("boolean", "boolean()");
|
||||
typeMapping.put("string", "binary()");
|
||||
typeMapping.put("integer", "integer()");
|
||||
typeMapping.put("int", "integer()");
|
||||
typeMapping.put("float", "integer()");
|
||||
typeMapping.put("long", "integer()");
|
||||
typeMapping.put("double", "float()");
|
||||
typeMapping.put("array", "list()");
|
||||
typeMapping.put("map", "maps:map()");
|
||||
typeMapping.put("number", "integer()");
|
||||
typeMapping.put("bigdecimal", "float()");
|
||||
typeMapping.put("List", "list()");
|
||||
typeMapping.put("object", "maps:map()");
|
||||
typeMapping.put("file", "binary()");
|
||||
typeMapping.put("binary", "binary()");
|
||||
typeMapping.put("bytearray", "binary()");
|
||||
typeMapping.put("byte", "binary()");
|
||||
typeMapping.put("uuid", "binary()");
|
||||
typeMapping.put("password", "binary()");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Erlang application name (convention: lowercase).")
|
||||
.defaultValue(this.packageName));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Erlang application version")
|
||||
.defaultValue(this.packageVersion));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String name) {
|
||||
return name + ":" + name + "()";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
String swaggerType = getSwaggerType(p);
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
return typeMapping.get(swaggerType);
|
||||
}
|
||||
return swaggerType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return (type);
|
||||
}
|
||||
else
|
||||
type = getTypeDeclaration(toModelName(snakeCase(swaggerType)));
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||
}
|
||||
else {
|
||||
setPackageName("swagger");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
||||
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
|
||||
}
|
||||
else {
|
||||
setPackageVersion("1.0.0");
|
||||
}
|
||||
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||
|
||||
additionalProperties.put("length", new Mustache.Lambda() {
|
||||
@Override
|
||||
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
|
||||
writer.write(length(fragment.context()));
|
||||
}
|
||||
});
|
||||
|
||||
additionalProperties.put("qsEncode", new Mustache.Lambda() {
|
||||
@Override
|
||||
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
|
||||
writer.write(qsEncode(fragment.context()));
|
||||
}
|
||||
});
|
||||
|
||||
modelPackage = packageName;
|
||||
apiPackage = packageName;
|
||||
|
||||
supportingFiles.add(new SupportingFile("rebar.config.mustache","", "rebar.config"));
|
||||
supportingFiles.add(new SupportingFile("app.src.mustache", "", "src" + File.separator + this.packageName + ".app.src"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
}
|
||||
|
||||
public String qsEncode(Object o) {
|
||||
String r = new String();
|
||||
CodegenParameter q = (CodegenParameter) o;
|
||||
if (q.isListContainer) {
|
||||
r += "[{<<\"" + q.baseName + "\">>, X} || X <- " + q.paramName + "]";
|
||||
} else {
|
||||
r += "{<<\"" + q.baseName + "\">>, " + q.paramName + "}";
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name)
|
||||
{
|
||||
// Can't start with an underscore, as our fields need to start with an
|
||||
// UppercaseLetter so that Go treats them as public/visible.
|
||||
|
||||
// Options?
|
||||
// - MyName
|
||||
// - AName
|
||||
// - TheName
|
||||
// - XName
|
||||
// - X_Name
|
||||
// ... or maybe a suffix?
|
||||
// - Name_ ... think this will work.
|
||||
if(this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return camelize(name) + '_';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = sanitizeName(name.replaceAll("-", "_"));
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
return camelize(toVarName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
return this.packageName + "_" + underscore(name.replaceAll("-", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return this.packageName + "_" + underscore(name.replaceAll("-", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return this.packageName + "_" + underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.erl => pet_api.erl
|
||||
return this.packageName + "_" + underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return underscore(operationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) operations.get("operation");
|
||||
List<ExtendedCodegenOperation> newOs = new ArrayList<ExtendedCodegenOperation>();
|
||||
Pattern pattern = Pattern.compile("(.*)\\{([^\\}]+)\\}(.*)");
|
||||
for (CodegenOperation o : os) {
|
||||
// force http method to lower case
|
||||
o.httpMethod = o.httpMethod.toLowerCase();
|
||||
|
||||
if (o.isListContainer) {
|
||||
o.returnType = "[" + o.returnBaseType + "]";
|
||||
}
|
||||
|
||||
ArrayList<String> pathTemplateNames = new ArrayList<String>();
|
||||
Matcher matcher = pattern.matcher(o.path);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String pathTemplateName = matcher.group(2);
|
||||
matcher.appendReplacement(buffer, "$1" + "\", " + camelize(pathTemplateName) + ", \"" + "$3");
|
||||
pathTemplateNames.add(pathTemplateName);
|
||||
}
|
||||
ExtendedCodegenOperation eco = new ExtendedCodegenOperation(o);
|
||||
if (buffer.toString().isEmpty()) {
|
||||
eco.setReplacedPathName(o.path);
|
||||
} else {
|
||||
eco.setReplacedPathName(buffer.toString());
|
||||
}
|
||||
eco.setPathTemplateNames(pathTemplateNames);
|
||||
newOs.add(eco);
|
||||
}
|
||||
operations.put("operation", newOs);
|
||||
return objs;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public void setPackageVersion(String packageVersion) {
|
||||
this.packageVersion = packageVersion;
|
||||
}
|
||||
|
||||
String length(Object o) {
|
||||
return Integer.toString((((ExtendedCodegenOperation) o).allParams).size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
class ExtendedCodegenOperation extends CodegenOperation {
|
||||
private List<String> pathTemplateNames = new ArrayList<String>();
|
||||
private String replacedPathName;
|
||||
|
||||
public ExtendedCodegenOperation(CodegenOperation o) {
|
||||
super();
|
||||
|
||||
// Copy all fields of CodegenOperation
|
||||
this.responseHeaders.addAll(o.responseHeaders);
|
||||
this.hasAuthMethods = o.hasAuthMethods;
|
||||
this.hasConsumes = o.hasConsumes;
|
||||
this.hasProduces = o.hasProduces;
|
||||
this.hasParams = o.hasParams;
|
||||
this.hasOptionalParams = o.hasOptionalParams;
|
||||
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
|
||||
this.returnSimpleType = o.returnSimpleType;
|
||||
this.subresourceOperation = o.subresourceOperation;
|
||||
this.isMapContainer = o.isMapContainer;
|
||||
this.isListContainer = o.isListContainer;
|
||||
this.isMultipart = o.isMultipart;
|
||||
this.hasMore = o.hasMore;
|
||||
this.isResponseBinary = o.isResponseBinary;
|
||||
this.hasReference = o.hasReference;
|
||||
this.isRestfulIndex = o.isRestfulIndex;
|
||||
this.isRestfulShow = o.isRestfulShow;
|
||||
this.isRestfulCreate = o.isRestfulCreate;
|
||||
this.isRestfulUpdate = o.isRestfulUpdate;
|
||||
this.isRestfulDestroy = o.isRestfulDestroy;
|
||||
this.isRestful = o.isRestful;
|
||||
this.path = o.path;
|
||||
this.operationId = o.operationId;
|
||||
this.returnType = o.returnType;
|
||||
this.httpMethod = o.httpMethod;
|
||||
this.returnBaseType = o.returnBaseType;
|
||||
this.returnContainer = o.returnContainer;
|
||||
this.summary = o.summary;
|
||||
this.unescapedNotes = o.unescapedNotes;
|
||||
this.notes = o.notes;
|
||||
this.baseName = o.baseName;
|
||||
this.defaultResponse = o.defaultResponse;
|
||||
this.discriminator = o.discriminator;
|
||||
this.consumes = o.consumes;
|
||||
this.produces = o.produces;
|
||||
this.bodyParam = o.bodyParam;
|
||||
this.allParams = o.allParams;
|
||||
this.bodyParams = o.bodyParams;
|
||||
this.pathParams = o.pathParams;
|
||||
this.queryParams = o.queryParams;
|
||||
this.headerParams = o.headerParams;
|
||||
this.formParams = o.formParams;
|
||||
this.authMethods = o.authMethods;
|
||||
this.tags = o.tags;
|
||||
this.responses = o.responses;
|
||||
this.imports = o.imports;
|
||||
this.examples = o.examples;
|
||||
this.externalDocs = o.externalDocs;
|
||||
this.vendorExtensions = o.vendorExtensions;
|
||||
this.nickname = o.nickname;
|
||||
this.operationIdLowerCase = o.operationIdLowerCase;
|
||||
this.operationIdCamelCase = o.operationIdCamelCase;
|
||||
}
|
||||
|
||||
public List<String> getPathTemplateNames() {
|
||||
return pathTemplateNames;
|
||||
}
|
||||
|
||||
public void setPathTemplateNames(List<String> pathTemplateNames) {
|
||||
this.pathTemplateNames = pathTemplateNames;
|
||||
}
|
||||
|
||||
public String getReplacedPathName() {
|
||||
return replacedPathName;
|
||||
}
|
||||
|
||||
public void setReplacedPathName(String replacedPathName) {
|
||||
this.replacedPathName = replacedPathName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,6 +306,27 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* read timeout (in milliseconds).
|
||||
* @return Read timeout
|
||||
*/
|
||||
public int getReadTimeout() {
|
||||
return readTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
* @param readTimeout Read timeout in milliseconds
|
||||
* @return API client
|
||||
*/
|
||||
public ApiClient setReadTimeout(int readTimeout) {
|
||||
this.readTimeout = readTimeout;
|
||||
httpClient.property(ClientProperties.READ_TIMEOUT, readTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date format used to parse/format date parameters.
|
||||
* @return Date format
|
||||
|
||||
@@ -426,7 +426,7 @@ public class ApiClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tempoaray folder path (for downloading files)
|
||||
* Set the temporary folder path (for downloading files)
|
||||
*
|
||||
* @param tempFolderPath Temporary folder path
|
||||
* @return ApiClient
|
||||
@@ -448,6 +448,7 @@ public class ApiClient {
|
||||
/**
|
||||
* Sets the connect timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param connectionTimeout connection timeout in milliseconds
|
||||
* @return Api client
|
||||
@@ -457,6 +458,50 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get read timeout (in milliseconds).
|
||||
*
|
||||
* @return Timeout in milliseconds
|
||||
*/
|
||||
public int getReadTimeout() {
|
||||
return httpClient.getReadTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the read timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param readTimeout read timeout in milliseconds
|
||||
* @return Api client
|
||||
*/
|
||||
public ApiClient setReadTimeout(int readTimeout) {
|
||||
httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get write timeout (in milliseconds).
|
||||
*
|
||||
* @return Timeout in milliseconds
|
||||
*/
|
||||
public int getWriteTimeout() {
|
||||
return httpClient.getWriteTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the write timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param writeTimeout connection timeout in milliseconds
|
||||
* @return Api client
|
||||
*/
|
||||
public ApiClient setWriteTimeout(int writeTimeout) {
|
||||
httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given parameter object into string.
|
||||
*
|
||||
|
||||
@@ -59,9 +59,18 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vendorExtensions.extraAnnotation}}
|
||||
{{{vendorExtensions.extraAnnotation}}}
|
||||
{{/vendorExtensions.extraAnnotation}}
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#isEnum}}{{^isListContainer}}{{^isMapContainer}}public {{datatype}} {{getter}}() {
|
||||
if ({{name}} == null) {
|
||||
return null;
|
||||
}
|
||||
return {{name}}.value();
|
||||
}{{/isMapContainer}}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isListContainer}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isMapContainer}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}{{/isMapContainer}}{{/isEnum}}{{^isEnum}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}{{/isEnum}}
|
||||
|
||||
{{^isReadOnly}}
|
||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
|
||||
@@ -13,6 +13,7 @@ io.swagger.codegen.languages.CsharpDotNet2ClientCodegen
|
||||
io.swagger.codegen.languages.DartClientCodegen
|
||||
io.swagger.codegen.languages.ElixirClientCodegen
|
||||
io.swagger.codegen.languages.EiffelClientCodegen
|
||||
io.swagger.codegen.languages.ErlangClientCodegen
|
||||
io.swagger.codegen.languages.ErlangServerCodegen
|
||||
io.swagger.codegen.languages.FinchServerCodegen
|
||||
io.swagger.codegen.languages.FlashClientCodegen
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Swagger client server library for Erlang
|
||||
|
||||
## Overview
|
||||
|
||||
An Erlang client stub generated by [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) given an OpenAPI/Swagger spec.
|
||||
@@ -0,0 +1,48 @@
|
||||
-module({{classname}}_api).
|
||||
|
||||
-export([{{#operations}}{{#operation}}{{^-first}},
|
||||
{{/-first}}{{operationId}}/{{#length}}{{allParams}}{{/length}}{{/operation}}{{/operations}}]).
|
||||
|
||||
-define(BASE_URL, <<"{{{basePath}}}">>).
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
%% @doc {{summary}}
|
||||
{{^notes.isEmpty}}
|
||||
%% {{notes}}
|
||||
{{/notes.isEmpty}}
|
||||
-spec {{operationId}}({{#allParams}}{{^-first}}, {{/-first}}{{dataType}}{{/allParams}}) -> {{#returnType}}{ok, list(), {{returnType}}} | {error, string()}{{/returnType}}{{^returnType}}ok | {error, integer()}{{/returnType}}.
|
||||
{{operationId}}({{#allParams}}{{^-first}}, {{/-first}}{{paramName}}{{/allParams}}) ->
|
||||
Method = {{httpMethod}},
|
||||
Path = ["{{{replacedPathName}}}"],
|
||||
QS = {{#queryParams.isEmpty}}[]{{/queryParams.isEmpty}}{{^queryParams.isEmpty}}lists:flatten([{{#queryParams}}{{^-first}}, {{/-first}}{{#qsEncode}}{{this}}{{/qsEncode}}{{/queryParams}}]){{/queryParams.isEmpty}},
|
||||
Headers = [{{^headerParams.isEmpty}}{{#headerParams}}{{^-first}}, {{/-first}}{<<"{{baseName}}">>, {{paramName}}}{{/headerParams}}{{/headerParams.isEmpty}}],
|
||||
Body1 = {{^formParams.isEmpty}}{form, [{{#formParams}}{{^-first}}, {{/-first}}{<<"{{baseName}}">>, {{paramName}}}{{/formParams}}]}{{/formParams.isEmpty}}{{#formParams.isEmpty}}{{#bodyParams.isEmpty}}[]{{/bodyParams.isEmpty}}{{^bodyParams.isEmpty}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/bodyParams.isEmpty}}{{/formParams.isEmpty}},
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{{#returnType}}
|
||||
{{#responses}}
|
||||
{{#isDefault}}
|
||||
{ok, {{code}}, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])}{{#hasMore}}; {{/hasMore}}
|
||||
{{/isDefault}}
|
||||
{{^isDefault}}
|
||||
{ok, {{code}}, _RespHeaders, _ClientRef} ->
|
||||
{error, "{{message}}"}{{#hasMore}}; {{/hasMore}}
|
||||
{{/isDefault}}
|
||||
{{/responses}}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
{{/returnType}}
|
||||
end.
|
||||
|
||||
{{/operation}}
|
||||
|
||||
{{/operations}}
|
||||
@@ -0,0 +1,17 @@
|
||||
{application, {{packageName}},
|
||||
[{description, {{#appDescription}}"{{appDescription}}"{{/appDescription}}{{^appDescription}}"Swagger client library"{{/appDescription}}},
|
||||
{vsn, "{{apiVersion}}"},
|
||||
{registered, []},
|
||||
{applications,
|
||||
[kernel,
|
||||
stdlib,
|
||||
ssl,
|
||||
hackney
|
||||
]},
|
||||
{env, []},
|
||||
{modules, []},
|
||||
|
||||
{maintainers, []},
|
||||
{licenses, [{{#licenseInfo}}"{{licenseInfo}}"{{/licenseInfo}}]},
|
||||
{links, [{{#infoUrl}}"{{infoUrl}}"{{/infoUrl}}]}
|
||||
]}.
|
||||
@@ -0,0 +1,21 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
-module({{classname}}).
|
||||
|
||||
-export_type([{{classname}}/0,
|
||||
encode/1,
|
||||
decode/1]).
|
||||
|
||||
-type {{classname}}() ::
|
||||
#{ {{#vars}}'{{name}}' {{#required}}:={{/required}}{{^required}}=>{{/required}} {{{datatype}}}{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
}.
|
||||
|
||||
encode(#{ {{#vars}}'{{name}}' := {{{nameInCamelCase}}}{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
}) ->
|
||||
#{ {{#vars}}'{{baseName}}' => {{{nameInCamelCase}}}{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
@@ -0,0 +1,3 @@
|
||||
{erl_opts, [debug_info, warnings_as_errors, warn_untyped_record]}.
|
||||
|
||||
{deps, [jsx, hackney]}.
|
||||
@@ -58,11 +58,27 @@ void
|
||||
void
|
||||
{{classname}}::fromJsonObject(QJsonObject &pJson) {
|
||||
{{#vars}}
|
||||
{{^isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{^isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}}
|
||||
{{#isListContainer}}
|
||||
{{#complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/complexType}}
|
||||
{{^complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}");{{/complexType}}
|
||||
{{/isContainer}}
|
||||
{{/isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
if( pJson["{{baseName}}"].isObject()){
|
||||
auto varmap = pJson["{{baseName}}"].toObject().toVariantMap();
|
||||
if(varmap.count() > 0){
|
||||
for(auto val : varmap.keys() ){
|
||||
{
|
||||
{{items.baseType}} *{{name}}_item = new {{items.baseType}}();
|
||||
auto jsonval = QJsonValue::fromVariant(varmap[val]);
|
||||
::{{cppNamespace}}::setValue(&{{name}}_item, jsonval, "{{items.baseType}}", "{{items.baseType}}");
|
||||
{{name}}->insert({{name}}->end(), val, {{name}}_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{/isMapContainer}}
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
@@ -83,14 +99,28 @@ QJsonObject*
|
||||
toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));{{/complexType}}{{^complexType}}
|
||||
if({{name}} != nullptr && *{{name}} != nullptr) {
|
||||
obj->insert("{{name}}", QJsonValue(*{{name}}));
|
||||
}{{/complexType}}{{/isContainer}}{{#isContainer}}
|
||||
}{{/complexType}}{{/isContainer}}{{#isListContainer}}
|
||||
QJsonArray {{name}}JsonArray;
|
||||
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
|
||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isContainer}}{{/complexType}}{{^complexType}}{{^isContainer}}
|
||||
obj->insert("{{baseName}}", QJsonValue({{name}}));{{/isContainer}}{{#isContainer}}
|
||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isListContainer}}{{#isMapContainer}}
|
||||
QJsonArray {{name}}JsonArray;
|
||||
for(auto keyval : {{name}}->keys()){
|
||||
QJsonObject {{name}}_jobj;
|
||||
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{complexType}}");
|
||||
{{name}}JsonArray.append({{name}}_jobj);
|
||||
}
|
||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isMapContainer}}{{/complexType}}{{^complexType}}{{^isContainer}}
|
||||
obj->insert("{{baseName}}", QJsonValue({{name}}));{{/isContainer}}{{#isListContainer}}
|
||||
QJsonArray {{name}}JsonArray;
|
||||
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}");
|
||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isContainer}}{{/complexType}}
|
||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isListContainer}}{{#isMapContainer}}
|
||||
QJsonArray {{name}}JsonArray;
|
||||
for(auto keyval : {{name}}->keys()){
|
||||
QJsonObject {{name}}_jobj;
|
||||
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{items.baseType}}");
|
||||
{{name}}JsonArray.append(portsobj);
|
||||
}
|
||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isMapContainer}}{{/complexType}}
|
||||
{{/vars}}
|
||||
|
||||
return obj;
|
||||
|
||||
@@ -12,7 +12,7 @@ case class {{classname}} (
|
||||
{{#description}}
|
||||
/* {{{description}}} */
|
||||
{{/description}}
|
||||
{{{name}}}: {{^required}}Option[{{/required}}{{datatype}}{{^required}}]{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{{name}}}: {{^required}}Option[{{/required}}{{datatype}}{{^required}}] = None{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/vars}}
|
||||
)
|
||||
|
||||
|
||||
19
pom.xml
19
pom.xml
@@ -837,18 +837,13 @@
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/scalatra</module>
|
||||
<!-- <module>samples/server/petstore/erlang-server</module> note: make sample compilation work -->
|
||||
<!-- clients -->
|
||||
<!--<module>samples/client/petstore/bash</module>-->
|
||||
<module>samples/client/petstore/ruby</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/client/petstore/akka-scala</module>
|
||||
<module>samples/client/petstore/javascript</module>
|
||||
<module>samples/client/petstore/python</module>
|
||||
<!-- <module>samples/client/petstore/haskell-http-client</module> -->
|
||||
<!-- <module>samples/client/petstore/haskell-http-client/tests-integration</module> -->
|
||||
<module>samples/client/petstore/typescript-fetch/builds/default</module>
|
||||
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
|
||||
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>
|
||||
@@ -858,20 +853,10 @@
|
||||
<module>samples/client/petstore/typescript-angularjs</module>-->
|
||||
<!-- comment out due to error `npm run build`
|
||||
<module>samples/client/petstore/typescript-jquery/npm</module>-->
|
||||
<module>samples/client/petstore/typescript-angular-v2/npm</module>
|
||||
<!--<module>samples/client/petstore/typescript-angular-v2/npm</module>-->
|
||||
<module>samples/client/petstore/typescript-angular-v4/npm</module>
|
||||
<module>samples/client/petstore/typescript-angular-v4.3/npm</module>
|
||||
<!-- comment out due to https://github.com/swagger-api/swagger-codegen/issues/6658
|
||||
<module>samples/client/petstore/swift3/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift3/promisekit/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift3/rxswift/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/promisekit/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/swift/rxswift/SwaggerClientTests</module>
|
||||
-->
|
||||
<!-- comment out objc tests as it's timing out
|
||||
<module>samples/client/petstore/objc/default/SwaggerClientTests</module>
|
||||
<module>samples/client/petstore/objc/core-data/SwaggerClientTests</module>-->
|
||||
<!--<module>samples/client/petstore/bash</module>-->
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
@@ -406,7 +406,7 @@ public class ApiClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tempoaray folder path (for downloading files)
|
||||
* Set the temporary folder path (for downloading files)
|
||||
*
|
||||
* @param tempFolderPath Temporary folder path
|
||||
* @return ApiClient
|
||||
@@ -428,6 +428,7 @@ public class ApiClient {
|
||||
/**
|
||||
* Sets the connect timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param connectionTimeout connection timeout in milliseconds
|
||||
* @return Api client
|
||||
@@ -437,6 +438,50 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get read timeout (in milliseconds).
|
||||
*
|
||||
* @return Timeout in milliseconds
|
||||
*/
|
||||
public int getReadTimeout() {
|
||||
return httpClient.getReadTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the read timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param readTimeout read timeout in milliseconds
|
||||
* @return Api client
|
||||
*/
|
||||
public ApiClient setReadTimeout(int readTimeout) {
|
||||
httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get write timeout (in milliseconds).
|
||||
*
|
||||
* @return Timeout in milliseconds
|
||||
*/
|
||||
public int getWriteTimeout() {
|
||||
return httpClient.getWriteTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the write timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param writeTimeout connection timeout in milliseconds
|
||||
* @return Api client
|
||||
*/
|
||||
public ApiClient setWriteTimeout(int writeTimeout) {
|
||||
httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given parameter object into string.
|
||||
*
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FakeApi {
|
||||
*/
|
||||
public com.squareup.okhttp.Call testCodeInjectEndRnNRCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object localVarPostBody = null;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/fake";
|
||||
|
||||
@@ -103,18 +103,14 @@ public class FakeApi {
|
||||
String[] localVarAuthNames = new String[] { };
|
||||
return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private com.squareup.okhttp.Call testCodeInjectEndRnNRValidateBeforeCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
|
||||
|
||||
|
||||
com.squareup.okhttp.Call call = testCodeInjectEndRnNRCall(testCodeInjectEndRnNR, progressListener, progressRequestListener);
|
||||
return call;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -211,7 +211,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wordnik.swagger</groupId>
|
||||
<artifactId>swagger-async-httpclient_2.11</artifactId>
|
||||
<artifactId>swagger-async-httpclient_2.10</artifactId>
|
||||
<version>${swagger-async-httpclient-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -40,10 +40,8 @@ import scala.concurrent._
|
||||
import scala.concurrent.duration._
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
class FakeApi(
|
||||
val defBasePath: String = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
|
||||
defApiInvoker: ApiInvoker = ApiInvoker
|
||||
) {
|
||||
class FakeApi(val defBasePath: String = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
|
||||
defApiInvoker: ApiInvoker = ApiInvoker) {
|
||||
|
||||
implicit val formats = new org.json4s.DefaultFormats {
|
||||
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
|
||||
@@ -55,13 +53,10 @@ class FakeApi(
|
||||
implicit val stringWriter = RequestWriters.StringWriter
|
||||
implicit val jsonWriter = JsonFormatsWriter
|
||||
|
||||
var basePath: String = defBasePath
|
||||
var apiInvoker: ApiInvoker = defApiInvoker
|
||||
|
||||
def addHeader(key: String, value: String): mutable.HashMap[String, String] = {
|
||||
apiInvoker.defaultHeaders += key -> value
|
||||
}
|
||||
var basePath = defBasePath
|
||||
var apiInvoker = defApiInvoker
|
||||
|
||||
def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
|
||||
val config = SwaggerConfig.forUrl(new URI(defBasePath))
|
||||
val client = new RestClient(config)
|
||||
val helper = new FakeApiAsyncHelper(client, config)
|
||||
@@ -90,6 +85,7 @@ class FakeApi(
|
||||
helper.testCodeInject * ' " =end rn n r(testCodeInjectEndRnNR)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class FakeApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||
|
||||
@@ -15,6 +15,6 @@ package io.swagger.client.model
|
||||
|
||||
case class ModelReturn (
|
||||
/* property description *_/ ' \" =end -- \\r\\n \\n \\r */
|
||||
_return: Option[Integer]
|
||||
_return: Option[Integer] = None
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# 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 Swagger Codgen 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 @@
|
||||
2.3.0-SNAPSHOT
|
||||
5
samples/client/petstore/erlang-client/README.md
Normal file
5
samples/client/petstore/erlang-client/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Swagger client server library for Erlang
|
||||
|
||||
## Overview
|
||||
|
||||
An Erlang client stub generated by [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) given an OpenAPI/Swagger spec.
|
||||
3
samples/client/petstore/erlang-client/rebar.config
Normal file
3
samples/client/petstore/erlang-client/rebar.config
Normal file
@@ -0,0 +1,3 @@
|
||||
{erl_opts, [debug_info, warnings_as_errors, warn_untyped_record]}.
|
||||
|
||||
{deps, [jsx, hackney]}.
|
||||
17
samples/client/petstore/erlang-client/src/swagger.app.src
Normal file
17
samples/client/petstore/erlang-client/src/swagger.app.src
Normal file
@@ -0,0 +1,17 @@
|
||||
{application, swagger,
|
||||
[{description, "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."},
|
||||
{vsn, ""},
|
||||
{registered, []},
|
||||
{applications,
|
||||
[kernel,
|
||||
stdlib,
|
||||
ssl,
|
||||
hackney
|
||||
]},
|
||||
{env, []},
|
||||
{modules, []},
|
||||
|
||||
{maintainers, []},
|
||||
{licenses, ["Apache 2.0"]},
|
||||
{links, []}
|
||||
]}.
|
||||
@@ -0,0 +1,20 @@
|
||||
-module(swagger_api_response).
|
||||
|
||||
-export_type([swagger_api_response/0,
|
||||
encode/1,
|
||||
decode/1]).
|
||||
|
||||
-type swagger_api_response() ::
|
||||
#{ 'code' => integer(),
|
||||
'type' => binary(),
|
||||
'message' => binary()
|
||||
}.
|
||||
|
||||
encode(#{ 'code' := Code,
|
||||
'type' := Type,
|
||||
'message' := Message
|
||||
}) ->
|
||||
#{ 'code' => Code,
|
||||
'type' => Type,
|
||||
'message' => Message
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
-module(swagger_category).
|
||||
|
||||
-export_type([swagger_category/0,
|
||||
encode/1,
|
||||
decode/1]).
|
||||
|
||||
-type swagger_category() ::
|
||||
#{ 'id' => integer(),
|
||||
'name' => binary()
|
||||
}.
|
||||
|
||||
encode(#{ 'id' := Id,
|
||||
'name' := Name
|
||||
}) ->
|
||||
#{ 'id' => Id,
|
||||
'name' => Name
|
||||
}
|
||||
29
samples/client/petstore/erlang-client/src/swagger_order.erl
Normal file
29
samples/client/petstore/erlang-client/src/swagger_order.erl
Normal file
@@ -0,0 +1,29 @@
|
||||
-module(swagger_order).
|
||||
|
||||
-export_type([swagger_order/0,
|
||||
encode/1,
|
||||
decode/1]).
|
||||
|
||||
-type swagger_order() ::
|
||||
#{ 'id' => integer(),
|
||||
'petId' => integer(),
|
||||
'quantity' => integer(),
|
||||
'shipDate' => swagger_date_time:swagger_date_time(),
|
||||
'status' => binary(),
|
||||
'complete' => boolean()
|
||||
}.
|
||||
|
||||
encode(#{ 'id' := Id,
|
||||
'petId' := PetId,
|
||||
'quantity' := Quantity,
|
||||
'shipDate' := ShipDate,
|
||||
'status' := Status,
|
||||
'complete' := Complete
|
||||
}) ->
|
||||
#{ 'id' => Id,
|
||||
'petId' => PetId,
|
||||
'quantity' => Quantity,
|
||||
'shipDate' => ShipDate,
|
||||
'status' => Status,
|
||||
'complete' => Complete
|
||||
}
|
||||
29
samples/client/petstore/erlang-client/src/swagger_pet.erl
Normal file
29
samples/client/petstore/erlang-client/src/swagger_pet.erl
Normal file
@@ -0,0 +1,29 @@
|
||||
-module(swagger_pet).
|
||||
|
||||
-export_type([swagger_pet/0,
|
||||
encode/1,
|
||||
decode/1]).
|
||||
|
||||
-type swagger_pet() ::
|
||||
#{ 'id' => integer(),
|
||||
'category' => swagger_category:swagger_category(),
|
||||
'name' := binary(),
|
||||
'photoUrls' := list(),
|
||||
'tags' => list(),
|
||||
'status' => binary()
|
||||
}.
|
||||
|
||||
encode(#{ 'id' := Id,
|
||||
'category' := Category,
|
||||
'name' := Name,
|
||||
'photoUrls' := PhotoUrls,
|
||||
'tags' := Tags,
|
||||
'status' := Status
|
||||
}) ->
|
||||
#{ 'id' => Id,
|
||||
'category' => Category,
|
||||
'name' => Name,
|
||||
'photoUrls' => PhotoUrls,
|
||||
'tags' => Tags,
|
||||
'status' => Status
|
||||
}
|
||||
165
samples/client/petstore/erlang-client/src/swagger_pet_api.erl
Normal file
165
samples/client/petstore/erlang-client/src/swagger_pet_api.erl
Normal file
@@ -0,0 +1,165 @@
|
||||
-module(swagger_pet_api).
|
||||
|
||||
-export([add_pet/1,
|
||||
delete_pet/2,
|
||||
find_pets_by_status/1,
|
||||
find_pets_by_tags/1,
|
||||
get_pet_by_id/1,
|
||||
update_pet/1,
|
||||
update_pet_with_form/3,
|
||||
upload_file/3]).
|
||||
|
||||
-define(BASE_URL, <<"http://petstore.swagger.io/v2">>).
|
||||
|
||||
%% @doc Add a new pet to the store
|
||||
-spec add_pet(swagger_pet:swagger_pet()) -> ok | {error, integer()}.
|
||||
add_pet(Body) ->
|
||||
Method = post,
|
||||
Path = ["/pet"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = Body,
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Deletes a pet
|
||||
-spec delete_pet(integer(), binary()) -> ok | {error, integer()}.
|
||||
delete_pet(PetId, ApiKey) ->
|
||||
Method = delete,
|
||||
Path = ["/pet/", PetId, ""],
|
||||
QS = [],
|
||||
Headers = [{<<"api_key">>, ApiKey}],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Finds Pets by status
|
||||
%% Multiple status values can be provided with comma separated strings
|
||||
-spec find_pets_by_status(list()) -> {ok, list(), [swagger_pet:swagger_pet()]} | {error, string()}.
|
||||
find_pets_by_status(Status) ->
|
||||
Method = get,
|
||||
Path = ["/pet/findByStatus"],
|
||||
QS = lists:flatten([[{<<"status">>, X} || X <- Status]]),
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])};
|
||||
{ok, 400, _RespHeaders, _ClientRef} ->
|
||||
{error, "Invalid status value"}
|
||||
end.
|
||||
|
||||
%% @doc Finds Pets by tags
|
||||
%% Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
-spec find_pets_by_tags(list()) -> {ok, list(), [swagger_pet:swagger_pet()]} | {error, string()}.
|
||||
find_pets_by_tags(Tags) ->
|
||||
Method = get,
|
||||
Path = ["/pet/findByTags"],
|
||||
QS = lists:flatten([[{<<"tags">>, X} || X <- Tags]]),
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])};
|
||||
{ok, 400, _RespHeaders, _ClientRef} ->
|
||||
{error, "Invalid tag value"}
|
||||
end.
|
||||
|
||||
%% @doc Find pet by ID
|
||||
%% Returns a single pet
|
||||
-spec get_pet_by_id(integer()) -> {ok, list(), swagger_pet:swagger_pet()} | {error, string()}.
|
||||
get_pet_by_id(PetId) ->
|
||||
Method = get,
|
||||
Path = ["/pet/", PetId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])};
|
||||
{ok, 400, _RespHeaders, _ClientRef} ->
|
||||
{error, "Invalid ID supplied"};
|
||||
{ok, 404, _RespHeaders, _ClientRef} ->
|
||||
{error, "Pet not found"}
|
||||
end.
|
||||
|
||||
%% @doc Update an existing pet
|
||||
-spec update_pet(swagger_pet:swagger_pet()) -> ok | {error, integer()}.
|
||||
update_pet(Body) ->
|
||||
Method = put,
|
||||
Path = ["/pet"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = Body,
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Updates a pet in the store with form data
|
||||
-spec update_pet_with_form(integer(), binary(), binary()) -> ok | {error, integer()}.
|
||||
update_pet_with_form(PetId, Name, Status) ->
|
||||
Method = post,
|
||||
Path = ["/pet/", PetId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = {form, [{<<"name">>, Name}, {<<"status">>, Status}]},
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc uploads an image
|
||||
-spec upload_file(integer(), binary(), binary()) -> {ok, list(), swagger_api_response:swagger_api_response()} | {error, string()}.
|
||||
upload_file(PetId, AdditionalMetadata, File) ->
|
||||
Method = post,
|
||||
Path = ["/pet/", PetId, "/uploadImage"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = {form, [{<<"additionalMetadata">>, AdditionalMetadata}, {<<"file">>, File}]},
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])}
|
||||
end.
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
-module(swagger_store_api).
|
||||
|
||||
-export([delete_order/1,
|
||||
get_inventory/0,
|
||||
get_order_by_id/1,
|
||||
place_order/1]).
|
||||
|
||||
-define(BASE_URL, <<"http://petstore.swagger.io/v2">>).
|
||||
|
||||
%% @doc Delete purchase order by ID
|
||||
%% For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
-spec delete_order(binary()) -> ok | {error, integer()}.
|
||||
delete_order(OrderId) ->
|
||||
Method = delete,
|
||||
Path = ["/store/order/", OrderId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Returns pet inventories by status
|
||||
%% Returns a map of status codes to quantities
|
||||
-spec get_inventory() -> {ok, list(), maps:map()} | {error, string()}.
|
||||
get_inventory() ->
|
||||
Method = get,
|
||||
Path = ["/store/inventory"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])}
|
||||
end.
|
||||
|
||||
%% @doc Find purchase order by ID
|
||||
%% For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
-spec get_order_by_id(integer()) -> {ok, list(), swagger_order:swagger_order()} | {error, string()}.
|
||||
get_order_by_id(OrderId) ->
|
||||
Method = get,
|
||||
Path = ["/store/order/", OrderId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])};
|
||||
{ok, 400, _RespHeaders, _ClientRef} ->
|
||||
{error, "Invalid ID supplied"};
|
||||
{ok, 404, _RespHeaders, _ClientRef} ->
|
||||
{error, "Order not found"}
|
||||
end.
|
||||
|
||||
%% @doc Place an order for a pet
|
||||
-spec place_order(swagger_order:swagger_order()) -> {ok, list(), swagger_order:swagger_order()} | {error, string()}.
|
||||
place_order(Body) ->
|
||||
Method = post,
|
||||
Path = ["/store/order"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = Body,
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])};
|
||||
{ok, 400, _RespHeaders, _ClientRef} ->
|
||||
{error, "Invalid Order"}
|
||||
end.
|
||||
|
||||
|
||||
17
samples/client/petstore/erlang-client/src/swagger_tag.erl
Normal file
17
samples/client/petstore/erlang-client/src/swagger_tag.erl
Normal file
@@ -0,0 +1,17 @@
|
||||
-module(swagger_tag).
|
||||
|
||||
-export_type([swagger_tag/0,
|
||||
encode/1,
|
||||
decode/1]).
|
||||
|
||||
-type swagger_tag() ::
|
||||
#{ 'id' => integer(),
|
||||
'name' => binary()
|
||||
}.
|
||||
|
||||
encode(#{ 'id' := Id,
|
||||
'name' := Name
|
||||
}) ->
|
||||
#{ 'id' => Id,
|
||||
'name' => Name
|
||||
}
|
||||
35
samples/client/petstore/erlang-client/src/swagger_user.erl
Normal file
35
samples/client/petstore/erlang-client/src/swagger_user.erl
Normal file
@@ -0,0 +1,35 @@
|
||||
-module(swagger_user).
|
||||
|
||||
-export_type([swagger_user/0,
|
||||
encode/1,
|
||||
decode/1]).
|
||||
|
||||
-type swagger_user() ::
|
||||
#{ 'id' => integer(),
|
||||
'username' => binary(),
|
||||
'firstName' => binary(),
|
||||
'lastName' => binary(),
|
||||
'email' => binary(),
|
||||
'password' => binary(),
|
||||
'phone' => binary(),
|
||||
'userStatus' => integer()
|
||||
}.
|
||||
|
||||
encode(#{ 'id' := Id,
|
||||
'username' := Username,
|
||||
'firstName' := FirstName,
|
||||
'lastName' := LastName,
|
||||
'email' := Email,
|
||||
'password' := Password,
|
||||
'phone' := Phone,
|
||||
'userStatus' := UserStatus
|
||||
}) ->
|
||||
#{ 'id' => Id,
|
||||
'username' => Username,
|
||||
'firstName' => FirstName,
|
||||
'lastName' => LastName,
|
||||
'email' => Email,
|
||||
'password' => Password,
|
||||
'phone' => Phone,
|
||||
'userStatus' => UserStatus
|
||||
}
|
||||
165
samples/client/petstore/erlang-client/src/swagger_user_api.erl
Normal file
165
samples/client/petstore/erlang-client/src/swagger_user_api.erl
Normal file
@@ -0,0 +1,165 @@
|
||||
-module(swagger_user_api).
|
||||
|
||||
-export([create_user/1,
|
||||
create_users_with_array_input/1,
|
||||
create_users_with_list_input/1,
|
||||
delete_user/1,
|
||||
get_user_by_name/1,
|
||||
login_user/2,
|
||||
logout_user/0,
|
||||
update_user/2]).
|
||||
|
||||
-define(BASE_URL, <<"http://petstore.swagger.io/v2">>).
|
||||
|
||||
%% @doc Create user
|
||||
%% This can only be done by the logged in user.
|
||||
-spec create_user(swagger_user:swagger_user()) -> ok | {error, integer()}.
|
||||
create_user(Body) ->
|
||||
Method = post,
|
||||
Path = ["/user"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = Body,
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Creates list of users with given input array
|
||||
-spec create_users_with_array_input(list()) -> ok | {error, integer()}.
|
||||
create_users_with_array_input(Body) ->
|
||||
Method = post,
|
||||
Path = ["/user/createWithArray"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = Body,
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Creates list of users with given input array
|
||||
-spec create_users_with_list_input(list()) -> ok | {error, integer()}.
|
||||
create_users_with_list_input(Body) ->
|
||||
Method = post,
|
||||
Path = ["/user/createWithList"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = Body,
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Delete user
|
||||
%% This can only be done by the logged in user.
|
||||
-spec delete_user(binary()) -> ok | {error, integer()}.
|
||||
delete_user(Username) ->
|
||||
Method = delete,
|
||||
Path = ["/user/", Username, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Get user by user name
|
||||
-spec get_user_by_name(binary()) -> {ok, list(), swagger_user:swagger_user()} | {error, string()}.
|
||||
get_user_by_name(Username) ->
|
||||
Method = get,
|
||||
Path = ["/user/", Username, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])};
|
||||
{ok, 400, _RespHeaders, _ClientRef} ->
|
||||
{error, "Invalid username supplied"};
|
||||
{ok, 404, _RespHeaders, _ClientRef} ->
|
||||
{error, "User not found"}
|
||||
end.
|
||||
|
||||
%% @doc Logs user into the system
|
||||
-spec login_user(binary(), binary()) -> {ok, list(), binary()} | {error, string()}.
|
||||
login_user(Username, Password) ->
|
||||
Method = get,
|
||||
Path = ["/user/login"],
|
||||
QS = lists:flatten([{<<"username">>, Username}, {<<"password">>, Password}]),
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, RespHeaders, ClientRef} ->
|
||||
{ok, Body} = hackney:body(ClientRef),
|
||||
{ok, RespHeaders, jsx:decode(Body, [returns_maps, {labels, attempt_atom}])};
|
||||
{ok, 400, _RespHeaders, _ClientRef} ->
|
||||
{error, "Invalid username/password supplied"}
|
||||
end.
|
||||
|
||||
%% @doc Logs out current logged in user session
|
||||
-spec logout_user() -> ok | {error, integer()}.
|
||||
logout_user() ->
|
||||
Method = get,
|
||||
Path = ["/user/logout"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
%% @doc Updated user
|
||||
%% This can only be done by the logged in user.
|
||||
-spec update_user(binary(), swagger_user:swagger_user()) -> ok | {error, integer()}.
|
||||
update_user(Username, Body) ->
|
||||
Method = put,
|
||||
Path = ["/user/", Username, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = Body,
|
||||
Opts = [],
|
||||
Url = hackney_url:make_url(?BASE_URL, Path, QS),
|
||||
|
||||
case hackney:request(Method, Url, Headers, Body1, Opts) of
|
||||
{ok, 200, _RespHeaders, _ClientRef} ->
|
||||
ok;
|
||||
{ok, Status, _RespHeaders, _ClientRef} ->
|
||||
{error, Status}
|
||||
end.
|
||||
|
||||
|
||||
@@ -408,7 +408,7 @@ public class ApiClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tempoaray folder path (for downloading files)
|
||||
* Set the temporary folder path (for downloading files)
|
||||
*
|
||||
* @param tempFolderPath Temporary folder path
|
||||
* @return ApiClient
|
||||
@@ -430,6 +430,7 @@ public class ApiClient {
|
||||
/**
|
||||
* Sets the connect timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param connectionTimeout connection timeout in milliseconds
|
||||
* @return Api client
|
||||
@@ -439,6 +440,50 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get read timeout (in milliseconds).
|
||||
*
|
||||
* @return Timeout in milliseconds
|
||||
*/
|
||||
public int getReadTimeout() {
|
||||
return httpClient.getReadTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the read timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param readTimeout read timeout in milliseconds
|
||||
* @return Api client
|
||||
*/
|
||||
public ApiClient setReadTimeout(int readTimeout) {
|
||||
httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get write timeout (in milliseconds).
|
||||
*
|
||||
* @return Timeout in milliseconds
|
||||
*/
|
||||
public int getWriteTimeout() {
|
||||
return httpClient.getWriteTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the write timeout (in milliseconds).
|
||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||
* {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @param writeTimeout connection timeout in milliseconds
|
||||
* @return Api client
|
||||
*/
|
||||
public ApiClient setWriteTimeout(int writeTimeout) {
|
||||
httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given parameter object into string.
|
||||
*
|
||||
|
||||
@@ -165,7 +165,33 @@ public class ApiClientTest {
|
||||
|
||||
apiClient.setConnectTimeout(10000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAndSetReadTimeout() {
|
||||
// read timeout defaults to 10 seconds
|
||||
assertEquals(10000, apiClient.getReadTimeout());
|
||||
assertEquals(10000, apiClient.getHttpClient().getReadTimeout());
|
||||
|
||||
apiClient.setReadTimeout(0);
|
||||
assertEquals(0, apiClient.getReadTimeout());
|
||||
assertEquals(0, apiClient.getHttpClient().getReadTimeout());
|
||||
|
||||
apiClient.setReadTimeout(10000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAndSetWriteTimeout() {
|
||||
// write timeout defaults to 10 seconds
|
||||
assertEquals(10000, apiClient.getWriteTimeout());
|
||||
assertEquals(10000, apiClient.getHttpClient().getWriteTimeout());
|
||||
|
||||
apiClient.setWriteTimeout(0);
|
||||
assertEquals(0, apiClient.getWriteTimeout());
|
||||
assertEquals(0, apiClient.getHttpClient().getWriteTimeout());
|
||||
|
||||
apiClient.setWriteTimeout(10000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairWhenNameIsInvalid() throws Exception {
|
||||
List<Pair> pairs_a = apiClient.parameterToPair(null, new Integer(1));
|
||||
|
||||
@@ -146,8 +146,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -179,8 +179,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -14,8 +14,8 @@ package io.swagger.client.model
|
||||
|
||||
|
||||
case class ApiResponse (
|
||||
code: Option[Integer],
|
||||
_type: Option[String],
|
||||
message: Option[String]
|
||||
code: Option[Integer] = None,
|
||||
_type: Option[String] = None,
|
||||
message: Option[String] = None
|
||||
)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ package io.swagger.client.model
|
||||
|
||||
|
||||
case class Category (
|
||||
id: Option[Long],
|
||||
name: Option[String]
|
||||
id: Option[Long] = None,
|
||||
name: Option[String] = None
|
||||
)
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ package io.swagger.client.model
|
||||
import java.util.Date
|
||||
|
||||
case class Order (
|
||||
id: Option[Long],
|
||||
petId: Option[Long],
|
||||
quantity: Option[Integer],
|
||||
shipDate: Option[Date],
|
||||
id: Option[Long] = None,
|
||||
petId: Option[Long] = None,
|
||||
quantity: Option[Integer] = None,
|
||||
shipDate: Option[Date] = None,
|
||||
/* Order Status */
|
||||
status: Option[String],
|
||||
complete: Option[Boolean]
|
||||
status: Option[String] = None,
|
||||
complete: Option[Boolean] = None
|
||||
)
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ package io.swagger.client.model
|
||||
|
||||
|
||||
case class Pet (
|
||||
id: Option[Long],
|
||||
category: Option[Category],
|
||||
id: Option[Long] = None,
|
||||
category: Option[Category] = None,
|
||||
name: String,
|
||||
photoUrls: List[String],
|
||||
tags: Option[List[Tag]],
|
||||
tags: Option[List[Tag]] = None,
|
||||
/* pet status in the store */
|
||||
status: Option[String]
|
||||
status: Option[String] = None
|
||||
)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ package io.swagger.client.model
|
||||
|
||||
|
||||
case class Tag (
|
||||
id: Option[Long],
|
||||
name: Option[String]
|
||||
id: Option[Long] = None,
|
||||
name: Option[String] = None
|
||||
)
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ package io.swagger.client.model
|
||||
|
||||
|
||||
case class User (
|
||||
id: Option[Long],
|
||||
username: Option[String],
|
||||
firstName: Option[String],
|
||||
lastName: Option[String],
|
||||
email: Option[String],
|
||||
password: Option[String],
|
||||
phone: Option[String],
|
||||
id: Option[Long] = None,
|
||||
username: Option[String] = None,
|
||||
firstName: Option[String] = None,
|
||||
lastName: Option[String] = None,
|
||||
email: Option[String] = None,
|
||||
password: Option[String] = None,
|
||||
phone: Option[String] = None,
|
||||
/* User Status */
|
||||
userStatus: Option[Integer]
|
||||
userStatus: Option[Integer] = None
|
||||
)
|
||||
|
||||
|
||||
@@ -146,8 +146,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -179,8 +179,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -146,8 +146,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -179,8 +179,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -108,6 +108,20 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 404, message = "Not found") })
|
||||
public void testEnumParameters(@Multipart(value = "enum_form_string_array", required = false) List<String> enumFormStringArray, @Multipart(value = "enum_form_string", required = false) String enumFormString, @HeaderParam("enum_header_string_array") List<String> enumHeaderStringArray, @HeaderParam("enum_header_string") String enumHeaderString, @QueryParam("enum_query_string_array") List<String> enumQueryStringArray, @QueryParam("enum_query_string") @DefaultValue("-efg") String enumQueryString, @QueryParam("enum_query_integer") Integer enumQueryInteger, @Multipart(value = "enum_query_double", required = false) Double enumQueryDouble);
|
||||
|
||||
/**
|
||||
* test inline additionalProperties
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
@Path("/fake/inline-additionalProperties")
|
||||
@Consumes({ "application/json" })
|
||||
@ApiOperation(value = "test inline additionalProperties", tags={ "fake", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
public void testInlineAdditionalProperties(@Valid Object param);
|
||||
|
||||
/**
|
||||
* test json serialization of form data
|
||||
*
|
||||
|
||||
@@ -92,8 +92,11 @@ public enum ArrayEnumEnum {
|
||||
* @return justSymbol
|
||||
**/
|
||||
@JsonProperty("just_symbol")
|
||||
public JustSymbolEnum getJustSymbol() {
|
||||
return justSymbol;
|
||||
public String getJustSymbol() {
|
||||
if (justSymbol == null) {
|
||||
return null;
|
||||
}
|
||||
return justSymbol.value();
|
||||
}
|
||||
|
||||
public void setJustSymbol(JustSymbolEnum justSymbol) {
|
||||
|
||||
@@ -128,8 +128,11 @@ public enum EnumNumberEnum {
|
||||
* @return enumString
|
||||
**/
|
||||
@JsonProperty("enum_string")
|
||||
public EnumStringEnum getEnumString() {
|
||||
return enumString;
|
||||
public String getEnumString() {
|
||||
if (enumString == null) {
|
||||
return null;
|
||||
}
|
||||
return enumString.value();
|
||||
}
|
||||
|
||||
public void setEnumString(EnumStringEnum enumString) {
|
||||
@@ -146,8 +149,11 @@ public enum EnumNumberEnum {
|
||||
* @return enumInteger
|
||||
**/
|
||||
@JsonProperty("enum_integer")
|
||||
public EnumIntegerEnum getEnumInteger() {
|
||||
return enumInteger;
|
||||
public Integer getEnumInteger() {
|
||||
if (enumInteger == null) {
|
||||
return null;
|
||||
}
|
||||
return enumInteger.value();
|
||||
}
|
||||
|
||||
public void setEnumInteger(EnumIntegerEnum enumInteger) {
|
||||
@@ -164,8 +170,11 @@ public enum EnumNumberEnum {
|
||||
* @return enumNumber
|
||||
**/
|
||||
@JsonProperty("enum_number")
|
||||
public EnumNumberEnum getEnumNumber() {
|
||||
return enumNumber;
|
||||
public Double getEnumNumber() {
|
||||
if (enumNumber == null) {
|
||||
return null;
|
||||
}
|
||||
return enumNumber.value();
|
||||
}
|
||||
|
||||
public void setEnumNumber(EnumNumberEnum enumNumber) {
|
||||
|
||||
@@ -141,8 +141,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -174,8 +174,11 @@ public enum StatusEnum {
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
|
||||
@@ -85,6 +85,18 @@ public class FakeApiServiceImpl implements FakeApi {
|
||||
// TODO: Implement...
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* test inline additionalProperties
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void testInlineAdditionalProperties(Object param) {
|
||||
// TODO: Implement...
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user