Skip to content

Commit

Permalink
Merge branch 'master' into scala-gatling-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma authored Dec 13, 2019
2 parents cc03569 + b930bb4 commit 269e191
Show file tree
Hide file tree
Showing 63 changed files with 522 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ public CodegenProperty fromProperty(String name, Property p) {
if (p instanceof IntegerProperty) {
IntegerProperty sp = (IntegerProperty) p;
property.isInteger = true;
property.isNumeric = true;
if (sp.getEnum() != null) {
List<Integer> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ private void postProcessEnumRefs(final Map<String, Object> models) {
// This is different in C# than most other generators, because enums in C# are compiled to integral types,
// while enums in many other languages are true objects.
CodegenModel refModel = enumRefs.get(var.datatype);
var.allowableValues = refModel.allowableValues;
var.allowableValues = new HashMap<>(refModel.allowableValues);
var.isEnum = true;

updateCodegenPropertyEnum(var);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
protected static final String LIBRARY_PROMISE_KIT = "PromiseKit";
protected static final String LIBRARY_RX_SWIFT = "RxSwift";
protected static final String[] RESPONSE_LIBRARIES = {LIBRARY_PROMISE_KIT, LIBRARY_RX_SWIFT};
protected static final String MODEL_CLASSES = "modelClasses";
protected String projectName = "SwaggerClient";
protected boolean unwrapRequired;
protected boolean objcCompatible = false;
Expand Down Expand Up @@ -302,6 +303,10 @@ public void processOpts() {
additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS);
}

if (additionalProperties.containsKey(MODEL_CLASSES)) {
additionalProperties.put("useModelClasses", true);
}

setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST));

supportingFiles.add(new SupportingFile("Podspec.mustache",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class Swift5Codegen extends DefaultCodegen implements CodegenConfig {
private static final String LIBRARY_PROMISE_KIT = "PromiseKit";
private static final String LIBRARY_RX_SWIFT = "RxSwift";
private static final String[] RESPONSE_LIBRARIES = {LIBRARY_PROMISE_KIT, LIBRARY_RX_SWIFT};
protected static final String MODEL_CLASSES = "modelClasses";
protected String projectName = "SwaggerClient";
private boolean unwrapRequired;
private boolean objcCompatible = false;
Expand Down Expand Up @@ -289,6 +290,10 @@ public void processOpts() {
additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS);
}

if (additionalProperties.containsKey(MODEL_CLASSES)) {
additionalProperties.put("useModelClasses", true);
}

setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST));

supportingFiles.add(new SupportingFile("Podspec.mustache",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
{{/joda}}
{{#java8}}
compile "org.glassfish.jersey.inject:jersey-hk2:$jersey_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
{{#supportJava6}}
compile "commons-io:commons-io:$commons_io_version"
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/supportJava6}}
{{#threetenbp}}
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version"
{{/threetenbp}}
{{^java8}}
compile "com.brsanthu:migbase64:2.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public:
void setConfiguration(std::shared_ptr<ApiConfiguration> configuration);
static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(bool value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(float value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ utility::string_t ApiClient::parameterToString(utility::string_t value)
{
return value;
}

utility::string_t ApiClient::parameterToString(bool value)
{
std::stringstream valueAsStringStream;
valueAsStringStream << (value ? "true" : "false");
return utility::conversions::to_string_t(valueAsStringStream.str());
}

utility::string_t ApiClient::parameterToString(int64_t value)
{
std::stringstream valueAsStringStream;
Expand Down Expand Up @@ -132,7 +140,20 @@ pplx::task<web::http::http_response> ApiClient::callApi(
if (!formParams.empty())
{
request.set_body(body_data);
}
}
}
else if (contentType == utility::conversions::to_string_t("multipart/form-data"))
{
MultipartFormData uploadData;
for (auto& kvp : formParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
std::stringstream data;
uploadData.writeTo(data);
auto bodyString = data.str();
auto length = bodyString.size();
request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void MultipartFormData::writeTo( std::ostream& target )
std::shared_ptr<HttpContent> content = m_Contents[i];
// boundary
target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";
target << (i > 0 ? "\r\n" : "") << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";
// headers
target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() );
Expand Down
2 changes: 1 addition & 1 deletion modules/swagger-codegen/src/main/resources/go/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
{{#hasFormParams}}
{{#formParams}}
{{#isFile}}
{{^required}}
var localVarFile {{dataType}}
{{^required}}
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
localVarFileOk := false
localVarFile, localVarFileOk = localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value().({{dataType}})
Expand Down
6 changes: 6 additions & 0 deletions modules/swagger-codegen/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@ use {{invokerPackage}}\ObjectSerializer;
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
}
{{/isBasic}}
{{#isBearer}}
// this endpoint requires Bearer token
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
{{/isBearer}}
{{#isOAuth}}
// this endpoint requires OAuth (access token)
if ($this->config->getAccessToken() !== null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

public struct {{classname}}: Codable {
public {{#useModelClasses}}class{{/useModelClasses}}{{^useModelClasses}}struct{{/useModelClasses}} {{classname}}: Codable {
{{#allVars}}
{{#isEnum}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

public struct {{classname}}: Codable {
public {{#useModelClasses}}class{{/useModelClasses}}{{^useModelClasses}}struct{{/useModelClasses}} {{classname}}: Codable {
{{#allVars}}
{{#isEnum}}
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3-SNAPSHOT
2.4.11-SNAPSHOT
25 changes: 23 additions & 2 deletions samples/client/petstore/cpprest/ApiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -43,6 +43,14 @@ utility::string_t ApiClient::parameterToString(utility::string_t value)
{
return value;
}

utility::string_t ApiClient::parameterToString(bool value)
{
std::stringstream valueAsStringStream;
valueAsStringStream << (value ? "true" : "false");
return utility::conversions::to_string_t(valueAsStringStream.str());
}

utility::string_t ApiClient::parameterToString(int64_t value)
{
std::stringstream valueAsStringStream;
Expand Down Expand Up @@ -144,7 +152,20 @@ pplx::task<web::http::http_response> ApiClient::callApi(
if (!formParams.empty())
{
request.set_body(body_data);
}
}
}
else if (contentType == utility::conversions::to_string_t("multipart/form-data"))
{
MultipartFormData uploadData;
for (auto& kvp : formParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
std::stringstream data;
uploadData.writeTo(data);
auto bodyString = data.str();
auto length = bodyString.size();
request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary());
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion samples/client/petstore/cpprest/ApiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -48,6 +48,7 @@ class ApiClient
void setConfiguration(std::shared_ptr<ApiConfiguration> configuration);

static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(bool value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(float value);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiException.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/HttpContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/HttpContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/IHttpBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/JsonBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/JsonBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ModelBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ModelBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/cpprest/MultipartFormData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -71,7 +71,7 @@ void MultipartFormData::writeTo( std::ostream& target )
std::shared_ptr<HttpContent> content = m_Contents[i];

// boundary
target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";
target << (i > 0 ? "\r\n" : "") << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";

// headers
target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() );
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/MultipartFormData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/PetApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/PetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
Loading

0 comments on commit 269e191

Please sign in to comment.