Merge remote-tracking branch 'origin/3.2.x' into 4.0.x

This commit is contained in:
William Cheng 2018-07-14 01:42:02 +08:00
commit deb5dcaad1
462 changed files with 9240 additions and 5502 deletions

3
.gitignore vendored
View File

@ -158,6 +158,9 @@ samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt
samples/client/petstore/python/.coverage
samples/client/petstore/python/.projectile
samples/client/petstore/python/.venv/
samples/client/petstore/python-asyncio/.venv/
samples/client/petstore/python-asyncio/.pytest_cache/
samples/client/petstore/python-tornado/.venv/
# ts
samples/client/petstore/typescript-node/npm/node_modules

View File

@ -1,32 +0,0 @@
#!/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 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/openapi-generator/src/main/resources/rails5 -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/rails5 $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -0,0 +1,32 @@
#!/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 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/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -27,6 +27,6 @@ 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/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-on-rails-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/ruby-on-rails $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -27,6 +27,6 @@ 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/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-sinatra-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/ruby-sinatra $@"
java $JAVA_OPTS -jar $executable $ags

6
bin/python-petstore-all.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# update python petstore clients
./bin/python-asyncio-petstore.sh
./bin/python-petstore.sh
./bin/python-tornado-petstore.sh

32
bin/ruby-client-petstore.sh Executable file
View File

@ -0,0 +1,32 @@
#!/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
# 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/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -27,6 +27,6 @@ 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/openapi-generator/src/main/resources/ruby -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-on-rails-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/ruby-on-rails $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -27,6 +27,6 @@ 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/openapi-generator/src/main/resources/rails5 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-on-rails -o samples/server/petstore/rails5 $@"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-sinatra-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/ruby-sinatra $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -27,6 +27,6 @@ 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/openapi-generator/src/main/resources/sinatra -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/sinatra $@"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore-security-test/ruby $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -1,32 +0,0 @@
#!/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
# 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/openapi-generator/src/main/resources/sinatra -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ruby-sinatra -o samples/server/petstore/sinatra $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -17,9 +17,9 @@ sleep 5
./bin/kotlin-client-petstore.sh > /dev/null 2>&1
./bin/kotlin-client-string.sh > /dev/null 2>&1
./bin/kotlin-client-threetenbp.sh > /dev/null 2>&1
./bin/kotlin-server-petstore.shl> /dev/null 2>&1
./bin/kotlin-server-petstore.sh > /dev/null 2>&1
./bin/php-petstore.sh > /dev/null 2>&1
./bin/php-silex-petstore-server.shj> /dev/null 2>&1
./bin/php-silex-petstore-server.sh > /dev/null 2>&1
./bin/php-symfony-petstore.sh > /dev/null 2>&1
./bin/php-lumen-petstore-server.sh > /dev/null 2>&1
./bin/php-slim-petstore-server.sh > /dev/null 2>&1

196
bin/utils/release_checkout.rb Executable file
View File

@ -0,0 +1,196 @@
#release_chekcout.rb
require 'rubygems'
require 'open-uri'
require 'net/http'
def check_homebrew
print "Checking homebrew forumla ... "
url = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/openapi-generator.rb"
new_maven_url = "https://search.maven.org/remotecontent?filepath=org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"
open(url) do |f|
content = f.read
if !content.nil? && content.include?(new_maven_url)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} not yet updated with #{new_maven_url}"
end
end
end
def check_openapi_generator_online_docker
print "Checking openapi-generator-online docker ... "
url = "https://hub.docker.com/r/openapitools/openapi-generator-online/tags/"
docker_tag = "v#{$version}"
open(url) do |f|
content = f.read
if !content.nil? && content.include?(docker_tag)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} does not have tag #{docker_tag}"
end
end
end
def check_openapi_generator_cli_docker
print "Checking openapi-generator-cli docker ... "
url = "https://hub.docker.com/r/openapitools/openapi-generator-cli/tags/"
docker_tag = "v#{$version}"
open(url) do |f|
content = f.read
if !content.nil? && content.include?(docker_tag)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} does not have tag #{docker_tag}"
end
end
end
def check_readme
print "Checking openapi-generator README.md ... "
url = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/README.md"
matches = ["[#{$version}](https://github.com/OpenAPITools/openapi-generator/releases/tag/v#{$version})",
"JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar`",
"wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar -O openapi-generator-cli.jar",
"Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"]
open(url) do |f|
content = f.read
has_outdated = false
not_matched = []
matches.each do |match|
if !content.nil? && content.include?(match)
# matched
else
has_outdated = true
not_matched << match
end
end
if has_outdated
puts "[ERROR]"
not_matched.each do |str|
puts "> '#{str}' not found in README.md"
end
else
puts "[OK]"
end
end
end
def check_openapi_generator_jar
print "Checking openapi-generator JAR ... "
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator/#{$version}/openapi-generator-#{$version}.jar"
if check_url(url)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} not found"
end
end
def check_openapi_generator_cli_jar
print "Checking openapi-generator-cli JAR ... "
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/#{$version}/openapi-generator-cli-#{$version}.jar"
if check_url(url)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} not found"
end
end
def check_openapi_generator_maven_plugin_jar
print "Checking openapi-generator-maven-plugin JAR ... "
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-maven-plugin/#{$version}/openapi-generator-maven-plugin-#{$version}.jar"
if check_url(url)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} not found"
end
end
def check_openapi_generator_gradle_plugin_jar
print "Checking openapi-generator-gradle-plugin JAR ... "
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-gradle-plugin/#{$version}/openapi-generator-gradle-plugin-#{$version}.jar"
if check_url(url)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} not found"
end
end
def check_openapi_generator_online_jar
print "Checking openapi-generator-online JAR ... "
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-online/#{$version}/openapi-generator-online-#{$version}.jar"
if check_url(url)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} not found"
end
end
def check_openapi_generator_project_pom
print "Checking openapi-generator-project pom.xml ... "
url = "http://central.maven.org/maven2/org/openapitools/openapi-generator-project/#{$version}/openapi-generator-project-#{$version}.pom"
if check_url(url)
puts "[OK]"
else
puts "[ERROR]"
puts "> #{url} not found"
end
end
def check_url url
content = Net::HTTP.get(URI.parse(url))
url = URI.parse(url)
req = Net::HTTP.new(url.host, url.port)
res = req.request_head(url.path)
if res.code == "200"
true
else
false
end
end
def usage
puts "ERROR!! Version (e.g. 3.0.2) missing"
puts "Usage example: ruby #{$0} 3.0.2"
end
if (!ARGV[0])
usage
exit
end
$version = ARGV[0]
puts "Running checkout on OpenAPI Generator release #{$version}"
check_homebrew
check_openapi_generator_jar
check_openapi_generator_cli_jar
check_openapi_generator_maven_plugin_jar
check_openapi_generator_gradle_plugin_jar
check_openapi_generator_online_jar
check_openapi_generator_project_pom
check_readme
check_openapi_generator_online_docker
check_openapi_generator_cli_docker

View File

@ -12,6 +12,13 @@ jobs:
DOCKER_GENERATOR_IMAGE_NAME: openapitools/openapi-generator
DOCKER_CODEGEN_CLI_IMAGE_NAME: openapitools/openapi-generator-cli
steps:
# Restore the dependency cache
- restore_cache:
keys:
# Default branch if not
- source-v1-{{ .Branch }}-{{ .Revision }}
- source-v1-{{ .Branch }}-
- source-v1-
# Machine Setup
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
@ -31,13 +38,6 @@ jobs:
' | sudo tee -a /etc/hosts
# Dependencies
# This would typically go in either a build or a build-and-test job when using workflows
# Restore the dependency cache
- restore_cache:
keys:
# This branch if available
- v1-dep-{{ .Branch }}-
# Default branch if not
- v1-dep-master-
# This is based on your 1.0 configuration file or project settings
- run: sudo add-apt-repository ppa:duggan/bats --yes
- run: sudo apt-get update -qq
@ -67,9 +67,22 @@ jobs:
- run: cat /etc/hosts
# This is based on your 1.0 configuration file or project settings
- run: cp CI/pom.xml.circleci pom.xml
# Test
# This would typically be a build job when using workflows, possibly combined with build
# This is based on your 1.0 configuration file or project settings
#- run: java -version
- run: mvn --quiet clean install
- run: mvn --quiet verify -Psamples
- run: if [ $? -ne 0 ]; then exit 1; fi
- run: sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
- run: java -version
- run: cp CI/pom.xml.circleci.java7 pom.xml
- run: mvn --quiet clean install
- run: mvn --quiet verify -Psamples
- run: if [ $? -ne 0 ]; then exit 1; fi
# Save dependency cache
- save_cache:
key: v1-dep-{{ .Branch }}
key: source-v1-{{ .Branch }}-{{ .Revision }}
paths:
# This is a broad list of cache paths to include many possible development environments
# You can probably delete some of these entries
@ -81,21 +94,7 @@ jobs:
- ~/.go_workspace
- ~/.gradle
- ~/.cache/bower
# These cache paths were specified in the 1.0 config
- ~/.sbt
# Test
# This would typically be a build job when using workflows, possibly combined with build
# This is based on your 1.0 configuration file or project settings
- run: java -version
- run: mvn --quiet clean install
- run: mvn --quiet verify -Psamples
- run: if [ $? -ne 0 ]; then exit 1; fi
- run: sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
- run: java -version
- run: cp CI/pom.xml.circleci.java7 pom.xml
- run: mvn --quiet clean install
- run: mvn --quiet verify -Psamples
- run: if [ $? -ne 0 ]; then exit 1; fi
- ".git"
# Teardown
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
# Save test results

View File

@ -37,3 +37,6 @@ Swagger is a trademark owned by SmartBear and the use of the term "Swagger" foun
OpenAPI Generator is based on Swagger Codegen 2.4.0-SNAPSHOT version so the migration should be easy, straightforward and almost seamless. Please refer to the [migration guide](migration-from-swagger-codegen.md) for more information.
#### May I know who maintains this Q&A page?
This Q&A page is maintained by the [core team members](../README.md#openapi-generator-core-team). It's not maintained by a single person nor do these Q&As represent the view of an individual.

View File

@ -19,6 +19,7 @@ package org.openapitools.codegen;
import io.airlift.airline.Cli;
import io.airlift.airline.Help;
import io.airlift.airline.ParseArgumentsUnexpectedException;
import io.airlift.airline.ParseOptionMissingException;
import io.airlift.airline.ParseOptionMissingValueException;
import org.openapitools.codegen.cmd.*;
@ -67,6 +68,9 @@ public class OpenAPIGenerator {
if (args.length == 0) {
System.exit(1);
}
} catch (ParseArgumentsUnexpectedException e) {
System.err.printf("[error] %s%n%nSee 'openapi-generator-cli help' for usage.%n", e.getMessage());
System.exit(1);
} catch (ParseOptionMissingException | ParseOptionMissingValueException e) {
System.err.printf("[error] %s%n", e.getMessage());
System.exit(1);

View File

@ -198,31 +198,16 @@
<guava-version>20.0</guava-version>
</properties>
<dependencies>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-core</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v3</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>com.samskivert</groupId>
<artifactId>jmustache</artifactId>

View File

@ -4373,19 +4373,16 @@ public class DefaultCodegen implements CodegenConfig {
if (schema.getAdditionalProperties() != null) {// http body is map
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
} else if (codegenProperty != null) {
LOGGER.warn("The following schema has undefined (null) baseType. " +
"It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " +
"A correct 'consumes' for form parameters should be " +
"'application/x-www-form-urlencoded' or 'multipart/form-data'");
LOGGER.warn("schema: " + schema);
LOGGER.warn("Defaulting baseType to UNKNOWN_BASE_TYPE");
codegenProperty.baseType = "UNKNOWN_BASE_TYPE";
codegenParameter.baseName = codegenProperty.baseType;
codegenParameter.baseType = codegenProperty.baseType;
codegenParameter.dataType = codegenProperty.dataType;
codegenParameter.description = codegenProperty.description;
codegenParameter.paramName = toParamName(codegenProperty.baseType);
if (StringUtils.isEmpty(bodyParameterName)) {
codegenParameter.baseName = codegenModel.classname;
} else {
codegenParameter.baseName = bodyParameterName;
}
codegenParameter.paramName = toParamName(codegenParameter.baseName);
codegenParameter.baseType = codegenModel.classname;
codegenParameter.dataType = getTypeDeclaration(codegenModel.classname);
codegenParameter.description = codegenModel.description;
imports.add(codegenParameter.baseType);
if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);

View File

@ -81,7 +81,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
apiTemplateFiles.put("api.mustache", ".rb");
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
embeddedTemplateDir = templateDir = "ruby";
embeddedTemplateDir = templateDir = "ruby-client";
modelTestTemplateFiles.put("model_test.mustache", ".rb");
apiTestTemplateFiles.put("api_test.mustache", ".rb");

View File

@ -85,7 +85,7 @@ public class RubyOnRailsServerCodegen extends DefaultCodegen implements CodegenC
modelPackage = "app/models";
modelTemplateFiles.put("model.mustache", ".rb");
embeddedTemplateDir = templateDir = "rails5";
embeddedTemplateDir = templateDir = "ruby-on-rails-server";
typeMapping.clear();
languageSpecificPrimitives.clear();

View File

@ -56,7 +56,7 @@ public class RubySinatraServerCodegen extends DefaultCodegen implements CodegenC
// no model
modelTemplateFiles.clear();
apiTemplateFiles.put("api.mustache", ".rb");
embeddedTemplateDir = templateDir = "sinatra";
embeddedTemplateDir = templateDir = "ruby-sinatra-server";
typeMapping.clear();
languageSpecificPrimitives.clear();

View File

@ -576,7 +576,9 @@ public class SpringCodegen extends AbstractJavaCodegen
allParams.add(p);
}
}
allParams.get(allParams.size()-1).hasMore =false;
if (!allParams.isEmpty()) {
allParams.get(allParams.size()-1).hasMore =false;
}
}
@Override

View File

@ -135,9 +135,21 @@ public class URLPathUtils {
}
private static String sanitizeUrl(String url) {
if (url.startsWith("/")) {
LOGGER.warn("'host' not defined in the spec (2.0). Default to " + LOCAL_HOST);
if (url.startsWith("//")) {
url = "http:" + url;
LOGGER.warn("'scheme' not defined in the spec (2.0). Default to [http] for server URL [{}]", url);
} else if (url.startsWith("/")) {
url = LOCAL_HOST + url;
LOGGER.warn("'host' not defined in the spec (2.0). Default to [{}] for server URL [{}]", LOCAL_HOST, url);
} else if (!url.matches("[a-zA-Z][0-9a-zA-Z.+\\-]+://.+")) {
// Add http scheme for urls without a scheme.
// 2.0 spec is restricted to the following schemes: "http", "https", "ws", "wss"
// 3.0 spec does not have an enumerated list of schemes
// This regex attempts to capture all schemes in IANA example schemes which
// can have alpha-numeric characters and [.+-]. Examples are here:
// https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
url = "http://" + url;
LOGGER.warn("'scheme' not defined in the spec (2.0). Default to [http] for server URL [{}]", url);
}
return url;

View File

@ -206,8 +206,8 @@
{{#useBeanValidation}}
<beanvalidation-version>1.1.0.Final</beanvalidation-version>
{{/useBeanValidation}}
<cxf-version>3.2.1</cxf-version>
<jackson-jaxrs-version>2.9.1</jackson-jaxrs-version>
<cxf-version>3.2.5</cxf-version>
<jackson-jaxrs-version>2.9.6</jackson-jaxrs-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -263,8 +263,8 @@
{{#generateSpringBootApplication}}
<spring.boot-version>1.5.9.RELEASE</spring.boot-version>
{{/generateSpringBootApplication}}
<cxf-version>3.2.1</cxf-version>
<jackson-jaxrs-version>2.9.1</jackson-jaxrs-version>
<cxf-version>3.2.5</cxf-version>
<jackson-jaxrs-version>2.9.6</jackson-jaxrs-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -67,9 +67,10 @@ type {{{nickname}}}Opts struct {
func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals *{{{nickname}}}Opts{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("{{httpMethod}}")
localVarPostBody interface{}
localVarFileName string
localVarFileBytes []byte
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
{{#returnType}}
localVarReturnValue {{{returnType}}}
{{/returnType}}
@ -177,6 +178,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
{{#hasFormParams}}
{{#formParams}}
{{#isFile}}
localVarFormFileName = "{{baseName}}"
{{#required}}
localVarFile := {{paramName}}
{{/required}}
@ -254,7 +256,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
{{/isApiKey}}
{{/authMethods}}
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
}

View File

@ -142,6 +142,8 @@ func parameterToString(obj interface{}, collectionFormat string) string {
if reflect.TypeOf(obj).Kind() == reflect.Slice {
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
} else if t, ok := obj.(time.Time); ok {
return t.Format(time.RFC3339)
}
return fmt.Sprintf("%v", obj)
@ -165,6 +167,7 @@ func (c *APIClient) prepareRequest(
headerParams map[string]string,
queryParams url.Values,
formParams url.Values,
formFileName string,
fileName string,
fileBytes []byte) (localVarRequest *http.Request, err error) {
@ -207,7 +210,7 @@ func (c *APIClient) prepareRequest(
if len(fileBytes) > 0 && fileName != "" {
w.Boundary()
//_, fileNm := filepath.Split(fileName)
part, err := w.CreateFormFile("file", filepath.Base(fileName))
part, err := w.CreateFormFile(formFileName, filepath.Base(fileName))
if err != nil {
return nil, err
}
@ -427,8 +430,9 @@ func CacheExpires(r *http.Response) time.Time {
lifetime, err := time.ParseDuration(maxAge + "s")
if err != nil {
expires = now
} else {
expires = now.Add(lifetime)
}
expires = now.Add(lifetime)
} else {
expiresHeader := r.Header.Get("Expires")
if expiresHeader != "" {

View File

@ -82,26 +82,27 @@ class {{classname}}(object):
returns the request thread.
"""
local_var_params = locals()
all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method {{operationId}}" % key
)
params[key] = val
del params['kwargs']
local_var_params[key] = val
del local_var_params['kwargs']
{{#allParams}}
{{#required}}
# verify the required parameter '{{paramName}}' is set
if ('{{paramName}}' not in params or
params['{{paramName}}'] is None):
if ('{{paramName}}' not in local_var_params or
local_var_params['{{paramName}}'] is None):
raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501
{{/required}}
{{/allParams}}
@ -109,35 +110,35 @@ class {{classname}}(object):
{{#allParams}}
{{#hasValidation}}
{{#maxLength}}
if ('{{paramName}}' in params and
len(params['{{paramName}}']) > {{maxLength}}):
if ('{{paramName}}' in local_var_params and
len(local_var_params['{{paramName}}']) > {{maxLength}}):
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501
{{/maxLength}}
{{#minLength}}
if ('{{paramName}}' in params and
len(params['{{paramName}}']) < {{minLength}}):
if ('{{paramName}}' in local_var_params and
len(local_var_params['{{paramName}}']) < {{minLength}}):
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501
{{/minLength}}
{{#maximum}}
if '{{paramName}}' in params and params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501
if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501
{{/maximum}}
{{#minimum}}
if '{{paramName}}' in params and params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501
if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501
{{/minimum}}
{{#pattern}}
if '{{paramName}}' in params and not re.search('{{{vendorExtensions.x-regex}}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501
if '{{paramName}}' in local_var_params and not re.search('{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501
{{/pattern}}
{{#maxItems}}
if ('{{paramName}}' in params and
len(params['{{paramName}}']) > {{maxItems}}):
if ('{{paramName}}' in local_var_params and
len(local_var_params['{{paramName}}']) > {{maxItems}}):
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501
{{/maxItems}}
{{#minItems}}
if ('{{paramName}}' in params and
len(params['{{paramName}}']) < {{minItems}}):
if ('{{paramName}}' in local_var_params and
len(local_var_params['{{paramName}}']) < {{minItems}}):
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501
{{/minItems}}
{{/hasValidation}}
@ -148,37 +149,37 @@ class {{classname}}(object):
path_params = {}
{{#pathParams}}
if '{{paramName}}' in params:
path_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501
if '{{paramName}}' in local_var_params:
path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501
{{/pathParams}}
query_params = []
{{#queryParams}}
if '{{paramName}}' in params:
query_params.append(('{{baseName}}', params['{{paramName}}'])){{#isListContainer}} # noqa: E501
if '{{paramName}}' in local_var_params:
query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isListContainer}} # noqa: E501
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501
{{/queryParams}}
header_params = {}
{{#headerParams}}
if '{{paramName}}' in params:
header_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501
if '{{paramName}}' in local_var_params:
header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501
{{/headerParams}}
form_params = []
local_var_files = {}
{{#formParams}}
if '{{paramName}}' in params:
{{^isFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501
if '{{paramName}}' in local_var_params:
{{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501
{{/formParams}}
body_params = None
{{#bodyParam}}
if '{{paramName}}' in params:
body_params = params['{{paramName}}']
if '{{paramName}}' in local_var_params:
body_params = local_var_params['{{paramName}}']
{{/bodyParam}}
{{#hasProduces}}
# HTTP header `Accept`
@ -205,10 +206,10 @@ class {{classname}}(object):
files=local_var_files,
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501
auth_settings=auth_settings,
async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
async=local_var_params.get('async'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)
{{/operation}}
{{/operations}}

View File

@ -125,17 +125,6 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
self.logger_file_handler.setFormatter(self.logger_formatter)
for _, logger in six.iteritems(self.logger):
logger.addHandler(self.logger_file_handler)
if self.logger_stream_handler:
logger.removeHandler(self.logger_stream_handler)
else:
# If not set logging file,
# then add stream handler and remove file handler.
self.logger_stream_handler = logging.StreamHandler()
self.logger_stream_handler.setFormatter(self.logger_formatter)
for _, logger in six.iteritems(self.logger):
logger.addHandler(self.logger_stream_handler)
if self.logger_file_handler:
logger.removeHandler(self.logger_file_handler)
@property
def debug(self):

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