Merge remote-tracking branch 'origin/5.4.x' into 6.0.x

This commit is contained in:
WILLIAM CHENG 2021-11-01 00:54:44 +08:00
commit 4f2b5ee36d
288 changed files with 4107 additions and 2113 deletions

View File

@ -42,24 +42,6 @@ jobs:
command: |- command: |-
printf '127.0.0.1 petstore.swagger.io printf '127.0.0.1 petstore.swagger.io
' | sudo tee -a /etc/hosts ' | sudo tee -a /etc/hosts
# Dependencies
# Install latest stable node for angular 6
- run:
name: Install node@stable (for angular 6)
command: |
set +e
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
#nvm install stable
# install v16 instead of the latest stable version
nvm install 16
nvm alias default 16
# Each step uses the same `$BASH_ENV`, so need to modify it
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
- run: node --version
# - run: docker pull openapitools/openapi-petstore # - run: docker pull openapitools/openapi-petstore
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore # - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
- run: docker pull swaggerapi/petstore - run: docker pull swaggerapi/petstore

View File

@ -40,6 +40,13 @@ elif [ "$NODE_INDEX" = "2" ]; then
sudo apt-get -y build-dep libcurl4-gnutls-dev sudo apt-get -y build-dep libcurl4-gnutls-dev
sudo apt-get -y install libcurl4-gnutls-dev sudo apt-get -y install libcurl4-gnutls-dev
# Install golang version 1.14
go version
sudo mkdir /usr/local/go1.14
wget -c https://dl.google.com/go/go1.14.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.14
export PATH="/usr/local/go1.14/go/bin:$PATH"
go version
# run integration tests # run integration tests
mvn --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error mvn --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
elif [ "$NODE_INDEX" = "3" ]; then elif [ "$NODE_INDEX" = "3" ]; then
@ -55,6 +62,21 @@ elif [ "$NODE_INDEX" = "3" ]; then
pyenv global 3.6.3 pyenv global 3.6.3
python3 --version python3 --version
# Install node@stable (for angular 6)
set +e
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
#nvm install stable
# install v16 instead of the latest stable version
nvm install 16
nvm alias default 16
node --version
# Each step uses the same `$BASH_ENV`, so need to modify it
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node3 -Dorg.slf4j.simpleLogger.defaultLogLevel=error mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node3 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
else else
@ -62,13 +84,6 @@ else
#sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 #sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
java -version java -version
# Install golang version 1.14
go version
sudo mkdir /usr/local/go1.14
wget -c https://dl.google.com/go/go1.14.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.14
export PATH="/usr/local/go1.14/go/bin:$PATH"
go version
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error mvn --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
fi fi

View File

@ -833,6 +833,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2021-05-31 - [FlutterでOpen Api Generator(Swagger)を使う](https://aakira.app/blog/2021/05/flutter-open-api/) by [AAkira](https://twitter.com/_a_akira) - 2021-05-31 - [FlutterでOpen Api Generator(Swagger)を使う](https://aakira.app/blog/2021/05/flutter-open-api/) by [AAkira](https://twitter.com/_a_akira)
- 2021-06-22 - [Rest API Documentation and Client Generation With OpenAPI](https://dzone.com/articles/rest-api-documentation-and-client-generation-with) by [Prasanth Gullapalli](https://dzone.com/users/1011797/prasanthnath.g@gmail.com.html) - 2021-06-22 - [Rest API Documentation and Client Generation With OpenAPI](https://dzone.com/articles/rest-api-documentation-and-client-generation-with) by [Prasanth Gullapalli](https://dzone.com/users/1011797/prasanthnath.g@gmail.com.html)
- 2021-07-16 - [銀行事業のサーバーサイド開発について / LINE 京都開発室 エンジニア採用説明会](https://www.youtube.com/watch?v=YrrKQHxLPpQ) by 野田誠人, Robert Mitchell - 2021-07-16 - [銀行事業のサーバーサイド開発について / LINE 京都開発室 エンジニア採用説明会](https://www.youtube.com/watch?v=YrrKQHxLPpQ) by 野田誠人, Robert Mitchell
- 2021-07-19 - [OpenAPI code generation with kotlin](https://sylhare.github.io/2021/07/19/Openapi-swagger-codegen-with-kotlin.html) by [sylhare](https://github.com/sylhare)
- 2021-07-29 - [How To Rewrite a Huge Codebase](https://dzone.com/articles/how-to-rewrite-a-huge-code-base) by [Curtis Poe](https://dzone.com/users/4565446/publiusovidius.html) - 2021-07-29 - [How To Rewrite a Huge Codebase](https://dzone.com/articles/how-to-rewrite-a-huge-code-base) by [Curtis Poe](https://dzone.com/users/4565446/publiusovidius.html)
- 2021-08-21 - [Generating Client APIs using Swagger Part 1](https://medium.com/@flowsquad/generating-client-apis-using-swagger-part-1-2d46f13f5e92) by [FlowSquad.io](https://medium.com/@flowsquad) - 2021-08-21 - [Generating Client APIs using Swagger Part 1](https://medium.com/@flowsquad/generating-client-apis-using-swagger-part-1-2d46f13f5e92) by [FlowSquad.io](https://medium.com/@flowsquad)
- 2021-09-11 - [Invoking AWS ParallelCluster API](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html) at [AWS ParallelCluster API official documentation](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html) - 2021-09-11 - [Invoking AWS ParallelCluster API](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html) at [AWS ParallelCluster API official documentation](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html)

View File

@ -2,3 +2,5 @@ generatorName: cpp-restsdk
outputDir: samples/client/petstore/cpp-restsdk/client outputDir: samples/client/petstore/cpp-restsdk/client
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/cpp-rest-sdk-client templateDir: modules/openapi-generator/src/main/resources/cpp-rest-sdk-client
additionalProperties:
packageName: CppRestPetstoreClient

View File

@ -5,3 +5,4 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties: additionalProperties:
artifactId: microprofile-rest-client artifactId: microprofile-rest-client
configKey: petstore

View File

@ -12,6 +12,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|defaultInclude|The default include statement that should be placed in all headers for including things like the declspec (convention: #include "Commons.h" | || |defaultInclude|The default include statement that should be placed in all headers for including things like the declspec (convention: #include "Commons.h" | ||
|generateGMocksForApis|Generate Google Mock classes for APIs.| |null| |generateGMocksForApis|Generate Google Mock classes for APIs.| |null|
|modelPackage|C++ namespace for models (convention: name.space.model).| |org.openapitools.client.model| |modelPackage|C++ namespace for models (convention: name.space.model).| |org.openapitools.client.model|
|packageName|C++ package (library) name.| |CppRestOpenAPIClient|
|packageVersion|C++ package version.| |1.0.0| |packageVersion|C++ package version.| |1.0.0|
|reservedWordPrefix|Prefix to prepend to reserved words in order to avoid conflicts| |r_| |reservedWordPrefix|Prefix to prepend to reserved words in order to avoid conflicts| |r_|
|variableNameFirstCharacterUppercase|Make first character of variable name uppercase (eg. value -> Value)| |true| |variableNameFirstCharacterUppercase|Make first character of variable name uppercase (eg. value -> Value)| |true|

View File

@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false| |bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get| |booleanGetterPrefix|Set booleanGetterPrefix| |get|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false| |caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|configKey|Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option.| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date (if you really have a good reason not to use threetenbp</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+) - note: this also sets &quot;java8&quot; to true</dd><dt>**threetenbp**</dt><dd>Backport of JSR310 (preferred for jdk &lt; 1.8)</dd></dl>|threetenbp| |dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date (if you really have a good reason not to use threetenbp</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+) - note: this also sets &quot;java8&quot; to true</dd><dt>**threetenbp**</dt><dd>Backport of JSR310 (preferred for jdk &lt; 1.8)</dd></dl>|threetenbp|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

View File

@ -0,0 +1,66 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen;
import java.util.*;
public class CodegenComposedSchemas {
private List<CodegenProperty> allOf;
private List<CodegenProperty> oneOf;
private List<CodegenProperty> anyOf;
public CodegenComposedSchemas(List<CodegenProperty> allOf, List<CodegenProperty> oneOf, List<CodegenProperty> anyOf) {
this.allOf = allOf;
this.oneOf = oneOf;
this.anyOf = anyOf;
}
public List<CodegenProperty> getAllOf() {
return allOf;
}
public List<CodegenProperty> getOneOf() {
return oneOf;
}
public List<CodegenProperty> getAnyOf() {
return anyOf;
}
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenComposedSchemas{");
sb.append("oneOf=").append(oneOf);
sb.append(", anyOf=").append(anyOf);
sb.append(", allOf=").append(allOf);
sb.append('}');
return sb.toString();
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CodegenComposedSchemas that = (CodegenComposedSchemas) o;
return Objects.equals(oneOf, that.oneOf) &&
Objects.equals(anyOf, that.anyOf) &&
Objects.equals(allOf, that.allOf);
}
@Override
public int hashCode() {
return Objects.hash(oneOf, anyOf, allOf);
}
}

View File

@ -49,11 +49,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public Set<String> oneOf = new TreeSet<String>(); public Set<String> oneOf = new TreeSet<String>();
public Set<String> allOf = new TreeSet<String>(); public Set<String> allOf = new TreeSet<String>();
// anyOf, oneOf, allOf with full properties/tags (e.g. isString, etc)
public List<CodegenProperty> anyOfProps = new ArrayList<>();
public List<CodegenProperty> allOfProps = new ArrayList<>();
public List<CodegenProperty> oneOfProps = new ArrayList<>();
// The schema name as written in the OpenAPI document. // The schema name as written in the OpenAPI document.
public String name; public String name;
// The language-specific name of the class that implements this schema. // The language-specific name of the class that implements this schema.
@ -110,6 +105,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public ExternalDocumentation externalDocumentation; public ExternalDocumentation externalDocumentation;
public Map<String, Object> vendorExtensions = new HashMap<String, Object>(); public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false;
/** /**
* The type of the value for the additionalProperties keyword in the OAS document. * The type of the value for the additionalProperties keyword in the OAS document.
@ -810,6 +807,22 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.isAnyType = isAnyType; this.isAnyType = isAnyType;
} }
@Override
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
this.composedSchemas = composedSchemas;
}
@Override
public CodegenComposedSchemas getComposedSchemas() {
return composedSchemas;
}
@Override
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
@Override
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@ -843,12 +856,14 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
hasOnlyReadOnly == that.hasOnlyReadOnly && hasOnlyReadOnly == that.hasOnlyReadOnly &&
isNull == that.isNull && isNull == that.isNull &&
hasValidation == that.hasValidation && hasValidation == that.hasValidation &&
hasMultipleTypes == that.getHasMultipleTypes() &&
hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() && hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() &&
getIsAnyType() == that.getIsAnyType() && getIsAnyType() == that.getIsAnyType() &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() && getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getUniqueItems() == that.getUniqueItems() && getUniqueItems() == that.getUniqueItems() &&
getExclusiveMinimum() == that.getExclusiveMinimum() && getExclusiveMinimum() == that.getExclusiveMinimum() &&
getExclusiveMaximum() == that.getExclusiveMaximum() && getExclusiveMaximum() == that.getExclusiveMaximum() &&
Objects.equals(composedSchemas, that.composedSchemas) &&
Objects.equals(parent, that.parent) && Objects.equals(parent, that.parent) &&
Objects.equals(parentSchema, that.parentSchema) && Objects.equals(parentSchema, that.parentSchema) &&
Objects.equals(interfaces, that.interfaces) && Objects.equals(interfaces, that.interfaces) &&
@ -856,9 +871,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
Objects.equals(parentModel, that.parentModel) && Objects.equals(parentModel, that.parentModel) &&
Objects.equals(interfaceModels, that.interfaceModels) && Objects.equals(interfaceModels, that.interfaceModels) &&
Objects.equals(children, that.children) && Objects.equals(children, that.children) &&
Objects.equals(anyOf, that.anyOfProps) &&
Objects.equals(oneOf, that.oneOfProps) &&
Objects.equals(allOf, that.allOfProps) &&
Objects.equals(anyOf, that.anyOf) && Objects.equals(anyOf, that.anyOf) &&
Objects.equals(oneOf, that.oneOf) && Objects.equals(oneOf, that.oneOf) &&
Objects.equals(allOf, that.allOf) && Objects.equals(allOf, that.allOf) &&
@ -921,8 +933,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(), getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(),
getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(), getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(),
getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(), getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(),
getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping, anyOfProps, oneOfProps, allOfProps, getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping,
isAnyType); isAnyType, getComposedSchemas(), hasMultipleTypes);
} }
@Override @Override
@ -938,9 +950,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", anyOf=").append(anyOf); sb.append(", anyOf=").append(anyOf);
sb.append(", oneOf=").append(oneOf); sb.append(", oneOf=").append(oneOf);
sb.append(", allOf=").append(allOf); sb.append(", allOf=").append(allOf);
sb.append(", anyOf=").append(anyOfProps);
sb.append(", oneOf=").append(oneOfProps);
sb.append(", allOf=").append(allOfProps);
sb.append(", name='").append(name).append('\''); sb.append(", name='").append(name).append('\'');
sb.append(", classname='").append(classname).append('\''); sb.append(", classname='").append(classname).append('\'');
sb.append(", title='").append(title).append('\''); sb.append(", title='").append(title).append('\'');
@ -1017,6 +1026,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", getAdditionalPropertiesIsAnyType=").append(getAdditionalPropertiesIsAnyType()); sb.append(", getAdditionalPropertiesIsAnyType=").append(getAdditionalPropertiesIsAnyType());
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
sb.append(", getIsAnyType=").append(getIsAnyType()); sb.append(", getIsAnyType=").append(getIsAnyType());
sb.append(", composedSchemas=").append(composedSchemas);
sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}'); sb.append('}');
return sb.toString(); return sb.toString();
} }

View File

@ -107,6 +107,8 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public boolean isNull; public boolean isNull;
private boolean hasRequired; private boolean hasRequired;
private boolean hasDiscriminatorWithNonEmptyMapping; private boolean hasDiscriminatorWithNonEmptyMapping;
private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false;
public CodegenParameter copy() { public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter(); CodegenParameter output = new CodegenParameter();
@ -158,7 +160,11 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
output.setHasVars(this.hasVars); output.setHasVars(this.hasVars);
output.setHasRequired(this.hasRequired); output.setHasRequired(this.hasRequired);
output.setHasDiscriminatorWithNonEmptyMapping(this.hasDiscriminatorWithNonEmptyMapping); output.setHasDiscriminatorWithNonEmptyMapping(this.hasDiscriminatorWithNonEmptyMapping);
output.setHasMultipleTypes(this.hasMultipleTypes);
if (this.composedSchemas != null) {
output.setComposedSchemas(this.getComposedSchemas());
}
if (this._enum != null) { if (this._enum != null) {
output._enum = new ArrayList<String>(this._enum); output._enum = new ArrayList<String>(this._enum);
} }
@ -216,7 +222,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping); return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes);
} }
@Override @Override
@ -264,13 +270,15 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
isDeprecated == that.isDeprecated && isDeprecated == that.isDeprecated &&
required == that.required && required == that.required &&
isNull == that.isNull && isNull == that.isNull &&
hasDiscriminatorWithNonEmptyMapping && that.getHasDiscriminatorWithNonEmptyMapping() && hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() && getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
hasMultipleTypes == that.getHasMultipleTypes() &&
getHasVars() == that.getHasVars() && getHasVars() == that.getHasVars() &&
getHasRequired() == that.getHasRequired() && getHasRequired() == that.getHasRequired() &&
getExclusiveMaximum() == that.getExclusiveMaximum() && getExclusiveMaximum() == that.getExclusiveMaximum() &&
getExclusiveMinimum() == that.getExclusiveMinimum() && getExclusiveMinimum() == that.getExclusiveMinimum() &&
getUniqueItems() == that.getUniqueItems() && getUniqueItems() == that.getUniqueItems() &&
Objects.equals(composedSchemas, that.getComposedSchemas()) &&
Objects.equals(baseName, that.baseName) && Objects.equals(baseName, that.baseName) &&
Objects.equals(paramName, that.paramName) && Objects.equals(paramName, that.paramName) &&
Objects.equals(dataType, that.dataType) && Objects.equals(dataType, that.dataType) &&
@ -393,6 +401,8 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
sb.append(", getHasVars=").append(hasVars); sb.append(", getHasVars=").append(hasVars);
sb.append(", getHasRequired=").append(hasRequired); sb.append(", getHasRequired=").append(hasRequired);
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
sb.append(", composedSchemas=").append(composedSchemas);
sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}'); sb.append('}');
return sb.toString(); return sb.toString();
} }
@ -706,5 +716,21 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public void setIsAnyType(boolean isAnyType) { public void setIsAnyType(boolean isAnyType) {
this.isAnyType = isAnyType; this.isAnyType = isAnyType;
} }
@Override
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
this.composedSchemas = composedSchemas;
}
@Override
public CodegenComposedSchemas getComposedSchemas() {
return composedSchemas;
}
@Override
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
@Override
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
} }

View File

@ -191,6 +191,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
private boolean hasVars; private boolean hasVars;
private boolean hasRequired; private boolean hasRequired;
private boolean hasDiscriminatorWithNonEmptyMapping; private boolean hasDiscriminatorWithNonEmptyMapping;
private CodegenComposedSchemas composedSchemas = null;
private boolean hasMultipleTypes = false;
public String getBaseName() { public String getBaseName() {
return baseName; return baseName;
@ -614,6 +616,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.xmlNamespace = xmlNamespace; this.xmlNamespace = xmlNamespace;
} }
@Override
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
this.composedSchemas = composedSchemas;
}
@Override
public CodegenComposedSchemas getComposedSchemas() {
return composedSchemas;
}
@Override @Override
public CodegenProperty clone() { public CodegenProperty clone() {
try { try {
@ -642,6 +654,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
if (this.vendorExtensions != null) { if (this.vendorExtensions != null) {
cp.vendorExtensions = new HashMap<String, Object>(this.vendorExtensions); cp.vendorExtensions = new HashMap<String, Object>(this.vendorExtensions);
} }
if (this.composedSchemas != null) {
cp.composedSchemas = this.composedSchemas;
}
return cp; return cp;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
@ -787,6 +802,12 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isAnyType = isAnyType; this.isAnyType = isAnyType;
} }
@Override
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
@Override
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{"); final StringBuilder sb = new StringBuilder("CodegenProperty{");
@ -882,6 +903,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
sb.append(", getHasVars=").append(getHasVars()); sb.append(", getHasVars=").append(getHasVars());
sb.append(", getHasRequired=").append(getHasRequired()); sb.append(", getHasRequired=").append(getHasRequired());
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
sb.append(", composedSchemas=").append(composedSchemas);
sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}'); sb.append('}');
return sb.toString(); return sb.toString();
} }
@ -933,10 +956,12 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
isXmlAttribute == that.isXmlAttribute && isXmlAttribute == that.isXmlAttribute &&
isXmlWrapped == that.isXmlWrapped && isXmlWrapped == that.isXmlWrapped &&
isNull == that.isNull && isNull == that.isNull &&
hasMultipleTypes == that.getHasMultipleTypes() &&
hasDiscriminatorWithNonEmptyMapping == that.hasDiscriminatorWithNonEmptyMapping && hasDiscriminatorWithNonEmptyMapping == that.hasDiscriminatorWithNonEmptyMapping &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() && getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getHasVars() == that.getHasVars() && getHasVars() == that.getHasVars() &&
getHasRequired() ==that.getHasRequired() && getHasRequired() ==that.getHasRequired() &&
Objects.equals(composedSchemas, that.composedSchemas) &&
Objects.equals(openApiType, that.openApiType) && Objects.equals(openApiType, that.openApiType) &&
Objects.equals(baseName, that.baseName) && Objects.equals(baseName, that.baseName) &&
Objects.equals(complexType, that.complexType) && Objects.equals(complexType, that.complexType) &&
@ -999,6 +1024,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase, vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName, nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
xmlNamespace, isXmlWrapped, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, xmlNamespace, isXmlWrapped, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired,
hasDiscriminatorWithNonEmptyMapping); hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes);
} }
} }

View File

@ -85,6 +85,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
private boolean hasVars; private boolean hasVars;
private boolean hasRequired; private boolean hasRequired;
private boolean hasDiscriminatorWithNonEmptyMapping; private boolean hasDiscriminatorWithNonEmptyMapping;
private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false;
@Override @Override
public int hashCode() { public int hashCode() {
@ -96,7 +98,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(), getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(), getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars, hasRequired, is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars, hasRequired,
hasDiscriminatorWithNonEmptyMapping); hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes);
} }
@Override @Override
@ -141,9 +143,11 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
is4xx == that.is4xx && is4xx == that.is4xx &&
is5xx == that.is5xx && is5xx == that.is5xx &&
hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() && hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() &&
hasMultipleTypes == that.getHasMultipleTypes() &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() && getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getHasVars() == that.getHasVars() && getHasVars() == that.getHasVars() &&
getHasRequired() == that.getHasRequired() && getHasRequired() == that.getHasRequired() &&
Objects.equals(composedSchemas, that.getComposedSchemas()) &&
Objects.equals(vars, that.vars) && Objects.equals(vars, that.vars) &&
Objects.equals(requiredVars, that.requiredVars) && Objects.equals(requiredVars, that.requiredVars) &&
Objects.equals(headers, that.headers) && Objects.equals(headers, that.headers) &&
@ -482,6 +486,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
sb.append(", getHasVars=").append(hasVars); sb.append(", getHasVars=").append(hasVars);
sb.append(", getHasRequired=").append(hasRequired); sb.append(", getHasRequired=").append(hasRequired);
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping); sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
sb.append(", composedSchemas=").append(composedSchemas);
sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}'); sb.append('}');
return sb.toString(); return sb.toString();
} }
@ -570,4 +576,20 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public void setIsAnyType(boolean isAnyType) { public void setIsAnyType(boolean isAnyType) {
this.isAnyType = isAnyType; this.isAnyType = isAnyType;
} }
@Override
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
this.composedSchemas = composedSchemas;
}
@Override
public CodegenComposedSchemas getComposedSchemas() {
return composedSchemas;
}
@Override
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
@Override
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
} }

View File

@ -2440,9 +2440,6 @@ public class DefaultCodegen implements CodegenConfig {
// interfaces (schemas defined in allOf, anyOf, oneOf) // interfaces (schemas defined in allOf, anyOf, oneOf)
List<Schema> interfaces = ModelUtils.getInterfaces(composed); List<Schema> interfaces = ModelUtils.getInterfaces(composed);
List<CodegenProperty> anyOfProps = new ArrayList<>();
List<CodegenProperty> allOfProps = new ArrayList<>();
List<CodegenProperty> oneOfProps = new ArrayList<>();
if (!interfaces.isEmpty()) { if (!interfaces.isEmpty()) {
// m.interfaces is for backward compatibility // m.interfaces is for backward compatibility
if (m.interfaces == null) if (m.interfaces == null)
@ -2467,7 +2464,6 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.warn("{} (anyOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType); LOGGER.warn("{} (anyOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType);
} else { } else {
m.anyOf.add(languageType); m.anyOf.add(languageType);
anyOfProps.add(interfaceProperty);
} }
} else if (composed.getOneOf() != null) { } else if (composed.getOneOf() != null) {
@ -2475,7 +2471,6 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.warn("{} (oneOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType); LOGGER.warn("{} (oneOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType);
} else { } else {
m.oneOf.add(languageType); m.oneOf.add(languageType);
oneOfProps.add(interfaceProperty);
} }
} else if (composed.getAllOf() != null) { } else if (composed.getAllOf() != null) {
// no need to add primitive type to allOf, which should comprise of schemas (models) only // no need to add primitive type to allOf, which should comprise of schemas (models) only
@ -2511,23 +2506,16 @@ public class DefaultCodegen implements CodegenConfig {
if (composed.getAnyOf() != null) { if (composed.getAnyOf() != null) {
m.anyOf.add(modelName); m.anyOf.add(modelName);
anyOfProps.add(interfaceProperty);
} else if (composed.getOneOf() != null) { } else if (composed.getOneOf() != null) {
m.oneOf.add(modelName); m.oneOf.add(modelName);
oneOfProps.add(interfaceProperty);
} else if (composed.getAllOf() != null) { } else if (composed.getAllOf() != null) {
m.allOf.add(modelName); m.allOf.add(modelName);
allOfProps.add(interfaceProperty);
} else { } else {
LOGGER.error("Composed schema has incorrect anyOf, allOf, oneOf defined: {}", composed); LOGGER.error("Composed schema has incorrect anyOf, allOf, oneOf defined: {}", composed);
} }
} }
} }
m.oneOfProps = oneOfProps;
m.allOfProps = allOfProps;
m.anyOfProps = anyOfProps;
if (parent != null && composed.getAllOf() != null) { // set parent for allOf only if (parent != null && composed.getAllOf() != null) { // set parent for allOf only
m.parentSchema = parentName; m.parentSchema = parentName;
m.parent = toModelName(parentName); m.parent = toModelName(parentName);
@ -2696,6 +2684,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
m.setTypeProperties(schema); m.setTypeProperties(schema);
m.setComposedSchemas(getComposedSchemas(schema));
if (ModelUtils.isArraySchema(schema)) { if (ModelUtils.isArraySchema(schema)) {
CodegenProperty arrayProperty = fromProperty(name, schema); CodegenProperty arrayProperty = fromProperty(name, schema);
m.setItems(arrayProperty.items); m.setItems(arrayProperty.items);
@ -3514,6 +3503,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
property.setTypeProperties(p); property.setTypeProperties(p);
property.setComposedSchemas(getComposedSchemas(p));
if (ModelUtils.isIntegerSchema(p)) { // integer type if (ModelUtils.isIntegerSchema(p)) { // integer type
property.isNumeric = Boolean.TRUE; property.isNumeric = Boolean.TRUE;
if (ModelUtils.isLongSchema(p)) { // int64/long format if (ModelUtils.isLongSchema(p)) { // int64/long format
@ -4265,6 +4255,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
r.setTypeProperties(responseSchema); r.setTypeProperties(responseSchema);
r.setComposedSchemas(getComposedSchemas(responseSchema));
if (ModelUtils.isArraySchema(responseSchema)) { if (ModelUtils.isArraySchema(responseSchema)) {
r.simpleType = false; r.simpleType = false;
r.containerType = cp.containerType; r.containerType = cp.containerType;
@ -4547,6 +4538,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
ModelUtils.syncValidationProperties(parameterSchema, codegenParameter); ModelUtils.syncValidationProperties(parameterSchema, codegenParameter);
codegenParameter.setTypeProperties(parameterSchema); codegenParameter.setTypeProperties(parameterSchema);
codegenParameter.setComposedSchemas(getComposedSchemas(parameterSchema));
if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec
codegenParameter.isNullable = true; codegenParameter.isNullable = true;
@ -6156,6 +6148,7 @@ public class DefaultCodegen implements CodegenConfig {
Schema ps = unaliasSchema(propertySchema, importMapping); Schema ps = unaliasSchema(propertySchema, importMapping);
ModelUtils.syncValidationProperties(ps, codegenParameter); ModelUtils.syncValidationProperties(ps, codegenParameter);
codegenParameter.setTypeProperties(ps); codegenParameter.setTypeProperties(ps);
codegenParameter.setComposedSchemas(getComposedSchemas(ps));
if (ps.getPattern() != null) { if (ps.getPattern() != null) {
codegenParameter.pattern = toRegularExpression(ps.getPattern()); codegenParameter.pattern = toRegularExpression(ps.getPattern());
} }
@ -6590,6 +6583,7 @@ public class DefaultCodegen implements CodegenConfig {
ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter); ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter);
codegenParameter.setTypeProperties(unaliasedSchema); codegenParameter.setTypeProperties(unaliasedSchema);
codegenParameter.setComposedSchemas(getComposedSchemas(unaliasedSchema));
// TODO in the future switch al the below schema usages to unaliasedSchema // TODO in the future switch al the below schema usages to unaliasedSchema
// because it keeps models as refs and will not get their referenced schemas // because it keeps models as refs and will not get their referenced schemas
if (ModelUtils.isArraySchema(schema)) { if (ModelUtils.isArraySchema(schema)) {
@ -7154,4 +7148,30 @@ public class DefaultCodegen implements CodegenConfig {
protected String getCollectionFormat(CodegenParameter codegenParameter) { protected String getCollectionFormat(CodegenParameter codegenParameter) {
return null; return null;
} }
private CodegenComposedSchemas getComposedSchemas(Schema schema) {
if (!(schema instanceof ComposedSchema)) {
return null;
}
ComposedSchema cs = (ComposedSchema) schema;
return new CodegenComposedSchemas(
getComposedProperties(cs.getAllOf(), "allOf"),
getComposedProperties(cs.getOneOf(), "oneOf"),
getComposedProperties(cs.getAnyOf(), "anyOf")
);
}
private List<CodegenProperty> getComposedProperties(List<Schema> xOfCollection, String collectionName) {
if (xOfCollection == null) {
return null;
}
List<CodegenProperty> xOf = new ArrayList<>();
int i = 0;
for (Schema xOfSchema: xOfCollection) {
CodegenProperty cp = fromProperty(collectionName + "_" + String.valueOf(i), xOfSchema);
xOf.add(cp);
i += 1;
}
return xOf;
}
} }

View File

@ -145,6 +145,14 @@ public interface IJsonSchemaValidationProperties {
void setIsAnyType(boolean isAnyType); void setIsAnyType(boolean isAnyType);
CodegenComposedSchemas getComposedSchemas();
void setComposedSchemas(CodegenComposedSchemas composedSchemas);
boolean getHasMultipleTypes();
void setHasMultipleTypes(boolean hasMultipleTypes);
/** /**
* Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance * Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance
* for now this only supports types without format information * for now this only supports types without format information

View File

@ -38,10 +38,13 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
public static final String DECLSPEC = "declspec"; public static final String DECLSPEC = "declspec";
public static final String DEFAULT_INCLUDE = "defaultInclude"; public static final String DEFAULT_INCLUDE = "defaultInclude";
public static final String GENERATE_GMOCKS_FOR_APIS = "generateGMocksForApis"; public static final String GENERATE_GMOCKS_FOR_APIS = "generateGMocksForApis";
public static final String DEFAULT_PACKAGE_NAME = "CppRestOpenAPIClient";
protected String packageName = "";
protected String packageVersion = "1.0.0"; protected String packageVersion = "1.0.0";
protected String declspec = ""; protected String declspec = "";
protected String defaultInclude = ""; protected String defaultInclude = "";
protected String modelDirName = "model";
private final Set<String> parentModels = new HashSet<>(); private final Set<String> parentModels = new HashSet<>();
private final Multimap<String, CodegenModel> childrenByParent = ArrayListMultimap.create(); private final Multimap<String, CodegenModel> childrenByParent = ArrayListMultimap.create();
@ -119,6 +122,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
cliOptions.clear(); cliOptions.clear();
// CLI options // CLI options
addOption(CodegenConstants.PACKAGE_NAME, "C++ package (library) name.", DEFAULT_PACKAGE_NAME);
addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).", addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).",
this.modelPackage); this.modelPackage);
addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).", addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).",
@ -159,6 +163,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("cmake-lists.mustache", "", "CMakeLists.txt")); supportingFiles.add(new SupportingFile("cmake-lists.mustache", "", "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("cmake-config.mustache", "", "Config.cmake.in"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<String>(
@ -195,6 +200,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
packageName = (String) additionalProperties.getOrDefault(CodegenConstants.PACKAGE_NAME, DEFAULT_PACKAGE_NAME);
if (additionalProperties.containsKey(DECLSPEC)) { if (additionalProperties.containsKey(DECLSPEC)) {
declspec = additionalProperties.get(DECLSPEC).toString(); declspec = additionalProperties.get(DECLSPEC).toString();
} }
@ -212,6 +219,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
additionalProperties.put("gmockApis", "true"); additionalProperties.put("gmockApis", "true");
} }
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\.")); additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\."));
additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::")); additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::"));
additionalProperties.put("modelHeaderGuardPrefix", modelPackage.replaceAll("\\.", "_").toUpperCase(Locale.ROOT)); additionalProperties.put("modelHeaderGuardPrefix", modelPackage.replaceAll("\\.", "_").toUpperCase(Locale.ROOT));
@ -229,7 +237,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
*/ */
@Override @Override
public String modelFileFolder() { public String modelFileFolder() {
return outputFolder + "/model"; return outputFolder + "/" + modelDirName;
} }
/** /**
@ -246,7 +254,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
if (importMapping.containsKey(name)) { if (importMapping.containsKey(name)) {
return importMapping.get(name); return importMapping.get(name);
} else { } else {
return "#include \"" + toModelFilename(name) + ".h\""; return "#include \"" + modelDirName + "/" + toModelFilename(name) + ".h\"";
} }
} }

View File

@ -56,6 +56,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String USE_PLAY_WS = "usePlayWS"; public static final String USE_PLAY_WS = "usePlayWS";
public static final String PLAY_VERSION = "playVersion"; public static final String PLAY_VERSION = "playVersion";
public static final String ASYNC_NATIVE = "asyncNative"; public static final String ASYNC_NATIVE = "asyncNative";
public static final String CONFIG_KEY = "configKey";
public static final String PARCELABLE_MODEL = "parcelableModel"; public static final String PARCELABLE_MODEL = "parcelableModel";
public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException"; public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException";
public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode"; public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode";
@ -102,6 +103,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
protected boolean usePlayWS = false; protected boolean usePlayWS = false;
protected String playVersion = PLAY_26; protected String playVersion = PLAY_26;
protected String microprofileFramework = MICROPROFILE_DEFAULT; protected String microprofileFramework = MICROPROFILE_DEFAULT;
protected String configKey = null;
protected boolean asyncNative = false; protected boolean asyncNative = false;
protected boolean parcelableModel = false; protected boolean parcelableModel = false;
@ -160,6 +162,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(DYNAMIC_OPERATIONS, "Generate operations dynamically at runtime from an OAS", this.dynamicOperations)); cliOptions.add(CliOption.newBoolean(DYNAMIC_OPERATIONS, "Generate operations dynamically at runtime from an OAS", this.dynamicOperations));
cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming)); cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming));
cliOptions.add(CliOption.newString(GRADLE_PROPERTIES, "Append additional Gradle proeprties to the gradle.properties file")); cliOptions.add(CliOption.newString(GRADLE_PROPERTIES, "Append additional Gradle proeprties to the gradle.properties file"));
cliOptions.add(CliOption.newString(CONFIG_KEY, "Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option."));
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libraries instead."); supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libraries instead.");
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x"); supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
@ -281,6 +284,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
} }
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework); additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);
if (additionalProperties.containsKey(CONFIG_KEY)) {
this.setConfigKey(additionalProperties.get(CONFIG_KEY).toString());
}
if (additionalProperties.containsKey(ASYNC_NATIVE)) { if (additionalProperties.containsKey(ASYNC_NATIVE)) {
this.setAsyncNative(convertPropertyToBooleanAndWriteBack(ASYNC_NATIVE)); this.setAsyncNative(convertPropertyToBooleanAndWriteBack(ASYNC_NATIVE));
} }
@ -964,6 +971,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
this.microprofileFramework = microprofileFramework; this.microprofileFramework = microprofileFramework;
} }
public void setConfigKey(String configKey) {
this.configKey = configKey;
}
public void setParcelableModel(boolean parcelableModel) { public void setParcelableModel(boolean parcelableModel) {
this.parcelableModel = parcelableModel; this.parcelableModel = parcelableModel;
} }

View File

@ -379,7 +379,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
} else if (interfaceOnly) { } else if (interfaceOnly) {
apiTemplateFiles.put("apiInterface.mustache", ".kt"); apiTemplateFiles.put("apiInterface.mustache", ".kt");
} else { } else {
apiTemplateFiles.put("api.mustache", ".kt"); apiTemplateFiles.put("api.mustache", "Controller.kt");
apiTestTemplateFiles.put("api_test.mustache", ".kt"); apiTestTemplateFiles.put("api_test.mustache", ".kt");
} }

View File

@ -44,6 +44,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static enum PROVIDED_IN_LEVEL {none, root, any, platform} public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
private static final String DEFAULT_IMPORT_PREFIX = "./"; private static final String DEFAULT_IMPORT_PREFIX = "./";
private static final String DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX = "../";
public static final String NPM_REPOSITORY = "npmRepository"; public static final String NPM_REPOSITORY = "npmRepository";
public static final String WITH_INTERFACES = "withInterfaces"; public static final String WITH_INTERFACES = "withInterfaces";
@ -634,7 +635,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
if (importMapping.containsKey(name)) { if (importMapping.containsKey(name)) {
return importMapping.get(name); return importMapping.get(name);
} }
return modelPackage() + "/" + toModelFilename(name).substring(DEFAULT_IMPORT_PREFIX.length()); return DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX + modelPackage() + "/" + toModelFilename(name).substring(DEFAULT_IMPORT_PREFIX.length());
} }
public String getNpmRepository() { public String getNpmRepository() {

View File

@ -708,15 +708,22 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
var.dataTypeAlternate = var.dataType; var.dataTypeAlternate = var.dataType;
if (var.isArray) { if (var.isArray) {
var.isUniqueId = var.isUniqueId || var.itemsAreUniqueId();
var.dataTypeAlternate = var.dataType.replace("Array<", "List<"); var.dataTypeAlternate = var.dataType.replace("Array<", "List<");
String newItemsDataType = var.getItemsDataType();
if (var.items.isModel) { if (var.items.isModel) {
String itemsDataType = var.items.dataType + "Record"; newItemsDataType = var.items.dataType + "Record";
var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, itemsDataType); var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, newItemsDataType);
} else if (var.items.isEnum) { } else if (var.items.isEnum) {
var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, var.items.datatypeWithEnum); newItemsDataType = var.items.datatypeWithEnum;
var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, newItemsDataType);
} else if (var.isUniqueId) {
newItemsDataType = "string";
var.dataTypeAlternate = var.dataTypeAlternate.replace("number", newItemsDataType);
} }
if (var.isUniqueId) {
var.dataTypeAlternate = var.dataTypeAlternate.replace("number", "string"); if (var.itemsAreNullable()) {
var.dataTypeAlternate = var.dataTypeAlternate.replace(newItemsDataType, newItemsDataType + " | null");
} }
} else if (var.isEnum) { } else if (var.isEnum) {
var.dataTypeAlternate = var.datatypeWithEnum; var.dataTypeAlternate = var.datatypeWithEnum;
@ -724,6 +731,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
var.dataTypeAlternate = var.dataType + "Record"; var.dataTypeAlternate = var.dataType + "Record";
} else if (var.isUniqueId) { } else if (var.isUniqueId) {
var.dataTypeAlternate = "string"; var.dataTypeAlternate = "string";
if (var.isNullable) {
var.dataTypeAlternate = var.dataTypeAlternate + " | null";
}
} }
if (var.defaultValue == null || var.defaultValue.equals("undefined")) { if (var.defaultValue == null || var.defaultValue.equals("undefined")) {
this.autoSetDefaultValueForProperty(var); this.autoSetDefaultValueForProperty(var);
@ -732,6 +742,10 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
return parentIsEntity; return parentIsEntity;
} }
private boolean itemsAreNullable(ExtendedCodegenProperty var) {
return var.items.isNullable || (var.items.items != null && var.items.items.isNullable);
}
private void escapeOperationIds(Map<String, Object> operations) { private void escapeOperationIds(Map<String, Object> operations) {
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations"); Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation"); List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
@ -816,19 +830,25 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
param.isUniqueId = this.isUniqueIdAccordingToNameSuffix(param.paramName); param.isUniqueId = this.isUniqueIdAccordingToNameSuffix(param.paramName);
} }
param.dataTypeAlternate = param.dataType; param.dataTypeAlternate = param.dataType;
if (param.isArray) { if (param.isArray) {
param.isUniqueId = param.isUniqueId || param.itemsAreUniqueId();
param.dataTypeAlternate = param.dataType.replace("Array<", "List<");
String newItemsDataType = param.getItemsDataType();
if (param.items.isModel) { if (param.items.isModel) {
String itemsDataType = param.items.dataType + "Record"; newItemsDataType = param.items.dataType + "Record";
param.dataTypeAlternate = param.dataType.replace("Array<", "List<"); param.dataTypeAlternate = param.dataTypeAlternate.replace(param.items.dataType, newItemsDataType);
param.dataTypeAlternate = param.dataTypeAlternate.replace(param.items.dataType, itemsDataType);
} else if (param.items.isEnum) { } else if (param.items.isEnum) {
newItemsDataType = param.datatypeWithEnum.substring(param.datatypeWithEnum.lastIndexOf("<") + 1, param.datatypeWithEnum.indexOf(">"));
param.dataTypeAlternate = param.datatypeWithEnum.replace("Array<", "List<"); param.dataTypeAlternate = param.datatypeWithEnum.replace("Array<", "List<");
} else { } else if (param.isUniqueId) {
param.dataTypeAlternate = param.dataType.replace("Array<", "List<"); newItemsDataType = "string";
param.dataTypeAlternate = param.dataTypeAlternate.replace("number", newItemsDataType);
} }
if (param.isUniqueId) {
param.dataTypeAlternate = param.dataTypeAlternate.replace("number", "string"); if (param.itemsAreNullable()) {
param.dataTypeAlternate = param.dataTypeAlternate.replace(newItemsDataType, newItemsDataType + " | null");
} }
} else if (param.isEnum) { } else if (param.isEnum) {
param.dataTypeAlternate = param.datatypeWithEnum; param.dataTypeAlternate = param.datatypeWithEnum;
@ -836,6 +856,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
param.dataTypeAlternate = param.dataType + "Record"; param.dataTypeAlternate = param.dataType + "Record";
} else if (param.isUniqueId) { } else if (param.isUniqueId) {
param.dataTypeAlternate = "string"; param.dataTypeAlternate = "string";
if (param.isNullable) {
param.dataTypeAlternate = param.dataTypeAlternate + " | null";
}
} }
} }
} }
@ -912,10 +935,46 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.prefixParameterInterfaces = prefixParameterInterfaces; this.prefixParameterInterfaces = prefixParameterInterfaces;
} }
private static boolean itemsAreUniqueId(CodegenProperty items) {
if (items.items != null) {
return itemsAreUniqueId(items.items);
};
if (items.vendorExtensions.get(X_IS_UNIQUE_ID) instanceof Boolean) {
return Boolean.TRUE.equals(items.vendorExtensions.get(X_IS_UNIQUE_ID));
}
return false;
}
private static boolean itemsAreNullable(CodegenProperty items) {
if (items.items != null) {
return itemsAreNullable(items.items);
};
return items.isNullable;
}
private static String getItemsDataType(CodegenProperty items) {
if (items.items != null) {
return getItemsDataType(items.items);
};
return items.dataType;
}
class ExtendedCodegenParameter extends CodegenParameter { class ExtendedCodegenParameter extends CodegenParameter {
public String dataTypeAlternate; public String dataTypeAlternate;
public boolean isUniqueId; // this parameter represents a unique id (x-isUniqueId: true) public boolean isUniqueId; // this parameter represents a unique id (x-isUniqueId: true)
public boolean itemsAreUniqueId() {
return TypeScriptFetchClientCodegen.itemsAreUniqueId(this.items);
}
public boolean itemsAreNullable() {
return TypeScriptFetchClientCodegen.itemsAreNullable(this.items);
}
public String getItemsDataType() {
return TypeScriptFetchClientCodegen.getItemsDataType(this.items);
}
public ExtendedCodegenParameter(CodegenParameter cp) { public ExtendedCodegenParameter(CodegenParameter cp) {
super(); super();
@ -1035,6 +1094,18 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public boolean keepAsJSObject; public boolean keepAsJSObject;
public boolean isReservedRecordField; public boolean isReservedRecordField;
public boolean itemsAreUniqueId() {
return TypeScriptFetchClientCodegen.itemsAreUniqueId(this.items);
}
public boolean itemsAreNullable() {
return TypeScriptFetchClientCodegen.itemsAreNullable(this.items);
}
public String getItemsDataType() {
return TypeScriptFetchClientCodegen.getItemsDataType(this.items);
}
public ExtendedCodegenProperty(CodegenProperty cp) { public ExtendedCodegenProperty(CodegenProperty cp) {
super(); super();

View File

@ -23,6 +23,7 @@ import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.context.FieldValueResolver; import com.github.jknack.handlebars.context.FieldValueResolver;
import com.github.jknack.handlebars.context.JavaBeanValueResolver; import com.github.jknack.handlebars.context.JavaBeanValueResolver;
import com.github.jknack.handlebars.context.MapValueResolver; import com.github.jknack.handlebars.context.MapValueResolver;
import com.github.jknack.handlebars.context.MethodValueResolver;
import com.github.jknack.handlebars.helper.ConditionalHelpers; import com.github.jknack.handlebars.helper.ConditionalHelpers;
import com.github.jknack.handlebars.helper.StringHelpers; import com.github.jknack.handlebars.helper.StringHelpers;
import com.github.jknack.handlebars.io.AbstractTemplateLoader; import com.github.jknack.handlebars.io.AbstractTemplateLoader;
@ -46,6 +47,7 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
// We use this as a simple lookup for valid file name extensions. This adapter will inspect .mustache (built-in) and infer the relevant handlebars filename // We use this as a simple lookup for valid file name extensions. This adapter will inspect .mustache (built-in) and infer the relevant handlebars filename
private final String[] canCompileFromExtensions = new String[]{".handlebars",".hbs",".mustache"}; private final String[] canCompileFromExtensions = new String[]{".handlebars",".hbs",".mustache"};
private boolean infiniteLoops = false; private boolean infiniteLoops = false;
private boolean prettyPrint = false;
/** /**
* Provides an identifier used to load the adapter. This could be a name, uuid, or any other string. * Provides an identifier used to load the adapter. This could be a name, uuid, or any other string.
@ -71,7 +73,8 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
.resolver( .resolver(
MapValueResolver.INSTANCE, MapValueResolver.INSTANCE,
JavaBeanValueResolver.INSTANCE, JavaBeanValueResolver.INSTANCE,
FieldValueResolver.INSTANCE) FieldValueResolver.INSTANCE,
MethodValueResolver.INSTANCE)
.build(); .build();
Handlebars handlebars = new Handlebars(loader); Handlebars handlebars = new Handlebars(loader);
@ -84,6 +87,7 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
handlebars.registerHelpers(ConditionalHelpers.class); handlebars.registerHelpers(ConditionalHelpers.class);
handlebars.registerHelpers(org.openapitools.codegen.templating.handlebars.StringHelpers.class); handlebars.registerHelpers(org.openapitools.codegen.templating.handlebars.StringHelpers.class);
handlebars.setInfiniteLoops(infiniteLoops); handlebars.setInfiniteLoops(infiniteLoops);
handlebars.setPrettyPrint(prettyPrint);
Template tmpl = handlebars.compile(templateFile); Template tmpl = handlebars.compile(templateFile);
return tmpl.apply(context); return tmpl.apply(context);
} }
@ -134,5 +138,9 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
this.infiniteLoops = infiniteLoops; this.infiniteLoops = infiniteLoops;
return this; return this;
} }
public void setPrettyPrint(boolean prettyPrint) {
this.prettyPrint = prettyPrint;
}
} }

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,14 +76,17 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.+' classpath 'com.android.tools.build:gradle:1.5.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -83,7 +82,7 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
{{#java8}} {{#java8}}
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
@ -94,9 +93,12 @@ if(hasProperty('target') && target == 'android') {
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
{{/java8}} {{/java8}}
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -5,6 +5,7 @@ import org.threeten.bp.*;
{{/threetenbp}} {{/threetenbp}}
import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.json.JsonMapper;
{{#openApiNullable}} {{#openApiNullable}}
import org.openapitools.jackson.nullable.JsonNullableModule; import org.openapitools.jackson.nullable.JsonNullableModule;
{{/openApiNullable}} {{/openApiNullable}}
@ -36,7 +37,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
public JSON() { public JSON() {
mapper = new ObjectMapper(); mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false); JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true); mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

View File

@ -121,7 +121,7 @@ ext {
threetenbp_version = "2.9.10" threetenbp_version = "2.9.10"
{{/threetenbp}} {{/threetenbp}}
{{#hasOAuthMethods}} {{#hasOAuthMethods}}
scribejava_apis_version = "6.9.0" scribejava_apis_version = "8.3.1"
{{/hasOAuthMethods}} {{/hasOAuthMethods}}
{{#hasHttpSignatureMethods}} {{#hasHttpSignatureMethods}}
tomitribe_http_signatures_version = "1.7" tomitribe_http_signatures_version = "1.7"

View File

@ -32,7 +32,7 @@ lazy val root = (project in file(".")).
"org.openapitools" % "jackson-databind-nullable" % "0.2.1" % "compile", "org.openapitools" % "jackson-databind-nullable" % "0.2.1" % "compile",
{{/openApiNullable}} {{/openApiNullable}}
{{#hasOAuthMethods}} {{#hasOAuthMethods}}
"com.github.scribejava" % "scribejava-apis" % "6.9.0" % "compile", "com.github.scribejava" % "scribejava-apis" % "8.3.1" % "compile",
{{/hasOAuthMethods}} {{/hasOAuthMethods}}
{{#hasHttpSignatureMethods}} {{#hasHttpSignatureMethods}}
"org.tomitribe" % "tomitribe-http-signatures" % "1.7" % "compile", "org.tomitribe" % "tomitribe-http-signatures" % "1.7" % "compile",

View File

@ -43,7 +43,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version> <version>3.0.0</version>
<executions> <executions>
<execution> <execution>
<id>enforce-maven</id> <id>enforce-maven</id>
@ -63,7 +63,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version> <version>3.0.0-M5</version>
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
@ -91,16 +91,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- attach test jar --> <!-- attach test jar -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.6</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>jar</goal>
<goal>test-jar</goal> <goal>test-jar</goal>
</goals> </goals>
</execution> </execution>
@ -108,11 +106,10 @@
<configuration> <configuration>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>add_sources</id> <id>add_sources</id>
@ -145,14 +142,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
{{#java8}}
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
{{/java8}}
{{^java8}}
<source>1.7</source>
<target>1.7</target>
{{/java8}}
<fork>true</fork> <fork>true</fork>
<meminitial>128m</meminitial> <meminitial>128m</meminitial>
<maxmem>512m</maxmem> <maxmem>512m</maxmem>
@ -165,7 +156,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<id>attach-javadocs</id> <id>attach-javadocs</id>
@ -176,12 +167,7 @@
</executions> </executions>
<configuration> <configuration>
<doclint>none</doclint> <doclint>none</doclint>
{{#java8}}
<source>1.8</source> <source>1.8</source>
{{/java8}}
{{^java8}}
<source>1.7</source>
{{/java8}}
<tags> <tags>
<tag> <tag>
<name>http.response.details</name> <name>http.response.details</name>
@ -194,7 +180,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
@ -305,13 +291,11 @@
<version>${jackson-version}</version> <version>${jackson-version}</version>
</dependency> </dependency>
{{/joda}} {{/joda}}
{{#java8}}
<dependency> <dependency>
<groupId>com.fasterxml.jackson.datatype</groupId> <groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId> <artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-version}</version> <version>${jackson-version}</version>
</dependency> </dependency>
{{/java8}}
{{#threetenbp}} {{#threetenbp}}
<dependency> <dependency>
<groupId>com.github.joschi.jackson</groupId> <groupId>com.github.joschi.jackson</groupId>
@ -319,14 +303,6 @@
<version>${threetenbp-version}</version> <version>${threetenbp-version}</version>
</dependency> </dependency>
{{/threetenbp}} {{/threetenbp}}
{{^java8}}
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>2.2</version>
</dependency>
{{/java8}}
{{#hasHttpSignatureMethods}} {{#hasHttpSignatureMethods}}
<dependency> <dependency>
<groupId>org.tomitribe</groupId> <groupId>org.tomitribe</groupId>
@ -388,7 +364,7 @@
<http-signature-version>1.7</http-signature-version> <http-signature-version>1.7</http-signature-version>
{{/hasHttpSignatureMethods}} {{/hasHttpSignatureMethods}}
{{#hasOAuthMethods}} {{#hasOAuthMethods}}
<scribejava-apis-version>6.9.0</scribejava-apis-version> <scribejava-apis-version>8.3.1</scribejava-apis-version>
{{/hasOAuthMethods}} {{/hasOAuthMethods}}
</properties> </properties>
</project> </project>

View File

@ -30,7 +30,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
*/ */
{{/appName}} {{/appName}}
@RegisterRestClient @RegisterRestClient{{#configKey}}(configKey="{{configKey}}"){{/configKey}}
@RegisterProvider(ApiExceptionMapper.class) @RegisterProvider(ApiExceptionMapper.class)
@Path("{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}{{commonPath}}") @Path("{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}{{commonPath}}")
public interface {{classname}} { public interface {{classname}} {

View File

@ -77,7 +77,7 @@
<dependency> <dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId> <groupId>org.eclipse.microprofile.rest.client</groupId>
<artifactId>microprofile-rest-client-api</artifactId> <artifactId>microprofile-rest-client-api</artifactId>
<version>1.2.1</version> <version>1.4.1</version>
</dependency> </dependency>
<!-- JAX-RS --> <!-- JAX-RS -->

View File

@ -6,18 +6,16 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
} }
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11
@ -33,9 +31,12 @@ javadoc {
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -72,6 +72,9 @@ import {{invokerPackage}}.auth.RetryingOAuth;
import {{invokerPackage}}.auth.OAuthFlow; import {{invokerPackage}}.auth.OAuthFlow;
{{/hasOAuthMethods}} {{/hasOAuthMethods}}
/**
* <p>ApiClient class.</p>
*/
public class ApiClient { public class ApiClient {
private String basePath = "{{{basePath}}}"; private String basePath = "{{{basePath}}}";
@ -100,7 +103,7 @@ public class ApiClient {
private Map<String, ApiOperation> operationLookupMap = new HashMap<>(); private Map<String, ApiOperation> operationLookupMap = new HashMap<>();
{{/dynamicOperations}} {{/dynamicOperations}}
/* /**
* Basic constructor for ApiClient * Basic constructor for ApiClient
*/ */
public ApiClient() { public ApiClient() {
@ -116,8 +119,10 @@ public class ApiClient {
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
} }
/* /**
* Basic constructor with custom OkHttpClient * Basic constructor with custom OkHttpClient
*
* @param client a {@link okhttp3.OkHttpClient} object
*/ */
public ApiClient(OkHttpClient client) { public ApiClient(OkHttpClient client) {
init(); init();
@ -136,28 +141,28 @@ public class ApiClient {
{{#hasOAuthMethods}} {{#hasOAuthMethods}}
{{#oauthMethods}} {{#oauthMethods}}
{{#-first}} {{#-first}}
/* /**
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID * Constructor for ApiClient to support access token retry on 401/403 configured with client ID
*/ */
public ApiClient(String clientId) { public ApiClient(String clientId) {
this(clientId, null, null); this(clientId, null, null);
} }
/* /**
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID and additional parameters * Constructor for ApiClient to support access token retry on 401/403 configured with client ID and additional parameters
*/ */
public ApiClient(String clientId, Map<String, String> parameters) { public ApiClient(String clientId, Map<String, String> parameters) {
this(clientId, null, parameters); this(clientId, null, parameters);
} }
/* /**
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID, secret, and additional parameters * Constructor for ApiClient to support access token retry on 401/403 configured with client ID, secret, and additional parameters
*/ */
public ApiClient(String clientId, String clientSecret, Map<String, String> parameters) { public ApiClient(String clientId, String clientSecret, Map<String, String> parameters) {
this(null, clientId, clientSecret, parameters); this(null, clientId, clientSecret, parameters);
} }
/* /**
* Constructor for ApiClient to support access token retry on 401/403 configured with base path, client ID, secret, and additional parameters * Constructor for ApiClient to support access token retry on 401/403 configured with base path, client ID, secret, and additional parameters
*/ */
public ApiClient(String basePath, String clientId, String clientSecret, Map<String, String> parameters) { public ApiClient(String basePath, String clientId, String clientSecret, Map<String, String> parameters) {
@ -264,7 +269,7 @@ public class ApiClient {
* *
* @param newHttpClient An instance of OkHttpClient * @param newHttpClient An instance of OkHttpClient
* @return Api Client * @return Api Client
* @throws NullPointerException when newHttpClient is null * @throws java.lang.NullPointerException when newHttpClient is null
*/ */
public ApiClient setHttpClient(OkHttpClient newHttpClient) { public ApiClient setHttpClient(OkHttpClient newHttpClient) {
this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!");
@ -336,6 +341,11 @@ public class ApiClient {
return this; return this;
} }
/**
* <p>Getter for the field <code>keyManagers</code>.</p>
*
* @return an array of {@link javax.net.ssl.KeyManager} objects
*/
public KeyManager[] getKeyManagers() { public KeyManager[] getKeyManagers() {
return keyManagers; return keyManagers;
} }
@ -353,15 +363,32 @@ public class ApiClient {
return this; return this;
} }
/**
* <p>Getter for the field <code>dateFormat</code>.</p>
*
* @return a {@link java.text.DateFormat} object
*/
public DateFormat getDateFormat() { public DateFormat getDateFormat() {
return dateFormat; return dateFormat;
} }
/**
* <p>Setter for the field <code>dateFormat</code>.</p>
*
* @param dateFormat a {@link java.text.DateFormat} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setDateFormat(DateFormat dateFormat) { public ApiClient setDateFormat(DateFormat dateFormat) {
this.json.setDateFormat(dateFormat); this.json.setDateFormat(dateFormat);
return this; return this;
} }
/**
* <p>Set SqlDateFormat.</p>
*
* @param dateFormat a {@link java.text.DateFormat} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setSqlDateFormat(DateFormat dateFormat) { public ApiClient setSqlDateFormat(DateFormat dateFormat) {
this.json.setSqlDateFormat(dateFormat); this.json.setSqlDateFormat(dateFormat);
return this; return this;
@ -380,17 +407,35 @@ public class ApiClient {
{{/joda}} {{/joda}}
{{#jsr310}} {{#jsr310}}
/**
* <p>Set OffsetDateTimeFormat.</p>
*
* @param dateFormat a {@link org.threeten.bp.format.DateTimeFormatter} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
this.json.setOffsetDateTimeFormat(dateFormat); this.json.setOffsetDateTimeFormat(dateFormat);
return this; return this;
} }
/**
* <p>Set LocalDateFormat.</p>
*
* @param dateFormat a {@link org.threeten.bp.format.DateTimeFormatter} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
this.json.setLocalDateFormat(dateFormat); this.json.setLocalDateFormat(dateFormat);
return this; return this;
} }
{{/jsr310}} {{/jsr310}}
/**
* <p>Set LenientOnJson.</p>
*
* @param lenientOnJson a boolean
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setLenientOnJson(boolean lenientOnJson) { public ApiClient setLenientOnJson(boolean lenientOnJson) {
this.json.setLenientOnJson(lenientOnJson); this.json.setLenientOnJson(lenientOnJson);
return this; return this;
@ -610,7 +655,7 @@ public class ApiClient {
/** /**
* Sets the connect timeout (in milliseconds). * Sets the connect timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}. * {@link java.lang.Integer#MAX_VALUE}.
* *
* @param connectionTimeout connection timeout in milliseconds * @param connectionTimeout connection timeout in milliseconds
* @return Api client * @return Api client
@ -632,7 +677,7 @@ public class ApiClient {
/** /**
* Sets the read timeout (in milliseconds). * Sets the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}. * {@link java.lang.Integer#MAX_VALUE}.
* *
* @param readTimeout read timeout in milliseconds * @param readTimeout read timeout in milliseconds
* @return Api client * @return Api client
@ -654,7 +699,7 @@ public class ApiClient {
/** /**
* Sets the write timeout (in milliseconds). * Sets the write timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}. * {@link java.lang.Integer#MAX_VALUE}.
* *
* @param writeTimeout connection timeout in milliseconds * @param writeTimeout connection timeout in milliseconds
* @return Api client * @return Api client
@ -945,7 +990,7 @@ public class ApiClient {
* @param response HTTP response * @param response HTTP response
* @param returnType The type of the Java object * @param returnType The type of the Java object
* @return The deserialized Java object * @return The deserialized Java object
* @throws ApiException If fail to deserialize response body, i.e. cannot read response body * @throws org.openapitools.client.ApiException If fail to deserialize response body, i.e. cannot read response body
* or the Content-Type of the response is not supported. * or the Content-Type of the response is not supported.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -1006,7 +1051,7 @@ public class ApiClient {
* @param obj The Java object * @param obj The Java object
* @param contentType The request Content-Type * @param contentType The request Content-Type
* @return The serialized request body * @return The serialized request body
* @throws ApiException If fail to serialize the given object * @throws org.openapitools.client.ApiException If fail to serialize the given object
*/ */
public RequestBody serialize(Object obj, String contentType) throws ApiException { public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) { if (obj instanceof byte[]) {
@ -1032,7 +1077,7 @@ public class ApiClient {
* Download file from the given response. * Download file from the given response.
* *
* @param response An instance of the Response object * @param response An instance of the Response object
* @throws ApiException If fail to read file content from response and write to disk * @throws org.openapitools.client.ApiException If fail to read file content from response and write to disk
* @return Downloaded file * @return Downloaded file
*/ */
public File downloadFileFromResponse(Response response) throws ApiException { public File downloadFileFromResponse(Response response) throws ApiException {
@ -1052,7 +1097,7 @@ public class ApiClient {
* *
* @param response An instance of the Response object * @param response An instance of the Response object
* @return Prepared file for the download * @return Prepared file for the download
* @throws IOException If fail to prepare file for download * @throws java.io.IOException If fail to prepare file for download
*/ */
public File prepareDownloadFile(Response response) throws IOException { public File prepareDownloadFile(Response response) throws IOException {
String filename = null; String filename = null;
@ -1096,7 +1141,7 @@ public class ApiClient {
* @param <T> Type * @param <T> Type
* @param call An instance of the Call object * @param call An instance of the Call object
* @return ApiResponse&lt;T&gt; * @return ApiResponse&lt;T&gt;
* @throws ApiException If fail to execute the call * @throws org.openapitools.client.ApiException If fail to execute the call
*/ */
public <T> ApiResponse<T> execute(Call call) throws ApiException { public <T> ApiResponse<T> execute(Call call) throws ApiException {
return execute(call, null); return execute(call, null);
@ -1111,7 +1156,7 @@ public class ApiClient {
* @return ApiResponse object containing response status, headers and * @return ApiResponse object containing response status, headers and
* data, which is a Java object deserialized from response body and would be null * data, which is a Java object deserialized from response body and would be null
* when returnType is null. * when returnType is null.
* @throws ApiException If fail to execute the call * @throws org.openapitools.client.ApiException If fail to execute the call
*/ */
public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException { public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
try { try {
@ -1124,6 +1169,14 @@ public class ApiClient {
} }
{{#supportStreaming}} {{#supportStreaming}}
/**
* <p>Execute stream.</p>
*
* @param call a {@link okhttp3.Call} object
* @param returnType a {@link java.lang.reflect.Type} object
* @return a {@link java.io.InputStream} object
* @throws org.openapitools.client.ApiException if any.
*/
public InputStream executeStream(Call call, Type returnType) throws ApiException { public InputStream executeStream(Call call, Type returnType) throws ApiException {
try { try {
Response response = call.execute(); Response response = call.execute();
@ -1192,7 +1245,7 @@ public class ApiClient {
* @param response Response * @param response Response
* @param returnType Return type * @param returnType Return type
* @return Type * @return Type
* @throws ApiException If the response has an unsuccessful status code or * @throws org.openapitools.client.ApiException If the response has an unsuccessful status code or
* fail to deserialize the response body * fail to deserialize the response body
*/ */
public <T> T handleResponse(Response response, Type returnType) throws ApiException { public <T> T handleResponse(Response response, Type returnType) throws ApiException {
@ -1238,7 +1291,7 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param callback Callback for upload/download progress * @param callback Callback for upload/download progress
* @return The HTTP call * @return The HTTP call
* @throws ApiException If fail to serialize the request body object * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/ */
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException { public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
@ -1260,7 +1313,7 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param callback Callback for upload/download progress * @param callback Callback for upload/download progress
* @return The HTTP request * @return The HTTP request
* @throws ApiException If fail to serialize the request body object * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/ */
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException { public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);

View File

@ -11,8 +11,6 @@ import java.util.TreeMap;
/** /**
* API response returned by API call. * API response returned by API call.
*
* @param <T> The type of data that is deserialized from response body
*/ */
public class ApiResponse<T> { public class ApiResponse<T> {
final private int statusCode; final private int statusCode;
@ -20,6 +18,8 @@ public class ApiResponse<T> {
final private T data; final private T data;
/** /**
* <p>Constructor for ApiResponse.</p>
*
* @param statusCode The status code of HTTP response * @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response * @param headers The headers of HTTP response
*/ */
@ -28,6 +28,8 @@ public class ApiResponse<T> {
} }
/** /**
* <p>Constructor for ApiResponse.</p>
*
* @param statusCode The status code of HTTP response * @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response * @param headers The headers of HTTP response
* @param data The object deserialized from response bod * @param data The object deserialized from response bod
@ -44,14 +46,29 @@ public class ApiResponse<T> {
this.data = data; this.data = data;
} }
/**
* <p>Get the <code>status code</code>.</p>
*
* @return the status code
*/
public int getStatusCode() { public int getStatusCode() {
return statusCode; return statusCode;
} }
/**
* <p>Get the <code>headers</code>.</p>
*
* @return a {@link java.util.Map} of headers
*/
public Map<String, List<String>> getHeaders() { public Map<String, List<String>> getHeaders() {
return headers; return headers;
} }
/**
* <p>Get the <code>data</code>.</p>
*
* @return the data
*/
public T getData() { public T getData() {
return data; return data;
} }

View File

@ -19,7 +19,7 @@
Building the API client library requires: Building the API client library requires:
1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+ 1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+
2. Maven/Gradle 2. Maven (3.8.3+)/Gradle (7.2+)
## Installation ## Installation
@ -55,7 +55,14 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file: Add this dependency to your project's build file:
```groovy ```groovy
compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}" repositories {
mavenCentral() // Needed if the '{{{artifactId}}}' jar has been published to maven central.
mavenLocal() // Needed if the '{{{artifactId}}}' jar has been published to the local maven repo.
}
dependencies {
implementation "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}"
}
``` ```
### Others ### Others

View File

@ -9,22 +9,47 @@ import java.util.Map.Entry;
import java.util.TreeMap; import java.util.TreeMap;
{{/caseInsensitiveResponseHeaders}} {{/caseInsensitiveResponseHeaders}}
/**
* <p>ApiException class.</p>
*/
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{ public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
private int code = 0; private int code = 0;
private Map<String, List<String>> responseHeaders = null; private Map<String, List<String>> responseHeaders = null;
private String responseBody = null; private String responseBody = null;
/**
* <p>Constructor for ApiException.</p>
*/
public ApiException() {} public ApiException() {}
/**
* <p>Constructor for ApiException.</p>
*
* @param throwable a {@link java.lang.Throwable} object
*/
public ApiException(Throwable throwable) { public ApiException(Throwable throwable) {
super(throwable); super(throwable);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
*/
public ApiException(String message) { public ApiException(String message) {
super(message); super(message);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
* @param throwable a {@link java.lang.Throwable} object
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
super(message, throwable); super(message, throwable);
this.code = code; this.code = code;
@ -38,23 +63,60 @@ public class ApiException extends{{#useRuntimeException}} RuntimeException {{/us
this.responseBody = responseBody; this.responseBody = responseBody;
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
this(message, (Throwable) null, code, responseHeaders, responseBody); this(message, (Throwable) null, code, responseHeaders, responseBody);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
* @param throwable a {@link java.lang.Throwable} object
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
*/
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) { public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
this(message, throwable, code, responseHeaders, null); this(message, throwable, code, responseHeaders, null);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
this((String) null, (Throwable) null, code, responseHeaders, responseBody); this((String) null, (Throwable) null, code, responseHeaders, responseBody);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param code HTTP status code
* @param message a {@link java.lang.String} object
*/
public ApiException(int code, String message) { public ApiException(int code, String message) {
super(message); super(message);
this.code = code; this.code = code;
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param code HTTP status code
* @param message the error message
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
this(code, message); this(code, message);
{{#caseInsensitiveResponseHeaders}} {{#caseInsensitiveResponseHeaders}}

View File

@ -57,7 +57,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version> <version>3.0.0</version>
<executions> <executions>
<execution> <execution>
<id>enforce-maven</id> <id>enforce-maven</id>
@ -77,7 +77,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version> <version>3.0.0-M5</version>
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
@ -104,16 +104,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- attach test jar --> <!-- attach test jar -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.2</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>jar</goal>
<goal>test-jar</goal> <goal>test-jar</goal>
</goals> </goals>
</execution> </execution>
@ -121,11 +119,10 @@
<configuration> <configuration>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>add_sources</id> <id>add_sources</id>
@ -156,7 +153,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<id>attach-javadocs</id> <id>attach-javadocs</id>
@ -179,7 +176,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
@ -200,7 +197,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId> <artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version> <version>3.0.1</version>
<executions> <executions>
<execution> <execution>
<id>sign-artifacts</id> <id>sign-artifacts</id>
@ -278,7 +275,7 @@
<dependency> <dependency>
<groupId>io.swagger.parser.v3</groupId> <groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v3</artifactId> <artifactId>swagger-parser-v3</artifactId>
<version>2.0.23</version> <version>2.0.28</version>
</dependency> </dependency>
{{/dynamicOperations}} {{/dynamicOperations}}
{{#useBeanValidation}} {{#useBeanValidation}}
@ -295,7 +292,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId> <artifactId>hibernate-validator</artifactId>
<version>5.4.1.Final</version> <version>5.4.3.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>jakarta.el</groupId> <groupId>jakarta.el</groupId>
@ -335,19 +332,19 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>3.11.2</version> <version>3.12.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version> <java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.8.5</gson-fire-version> <gson-fire-version>1.8.5</gson-fire-version>
<swagger-core-version>1.6.2</swagger-core-version> <swagger-core-version>1.6.3</swagger-core-version>
<okhttp-version>4.9.1</okhttp-version> <okhttp-version>4.9.2</okhttp-version>
<gson-version>2.8.6</gson-version> <gson-version>2.8.8</gson-version>
<commons-lang3-version>3.11</commons-lang3-version> <commons-lang3-version>3.12.0</commons-lang3-version>
{{#openApiNullable}} {{#openApiNullable}}
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version> <jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version>
{{/openApiNullable}} {{/openApiNullable}}
@ -364,7 +361,7 @@
{{#useBeanValidation}} {{#useBeanValidation}}
<beanvalidation-version>2.0.2</beanvalidation-version> <beanvalidation-version>2.0.2</beanvalidation-version>
{{/useBeanValidation}} {{/useBeanValidation}}
<junit-version>4.13.1</junit-version> <junit-version>4.13.2</junit-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
</project> </project>

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.+' classpath 'com.android.tools.build:gradle:1.5.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,14 +76,17 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.+' classpath 'com.android.tools.build:gradle:1.5.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,13 +76,17 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.+' classpath 'com.android.tools.build:gradle:1.5.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -83,7 +82,7 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
{{#java8}} {{#java8}}
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
@ -94,9 +93,12 @@ if(hasProperty('target') && target == 'android') {
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
{{/java8}} {{/java8}}
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -83,14 +82,17 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -83,7 +82,7 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
{{#java8}} {{#java8}}
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
@ -94,9 +93,12 @@ if(hasProperty('target') && target == 'android') {
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
{{/java8}} {{/java8}}
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -5,19 +5,21 @@ group = '{{groupId}}'
version = '{{artifactVersion}}' version = '{{artifactVersion}}'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,8 +15,7 @@ buildscript {
} }
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
if(hasProperty('target') && target == 'android') { if(hasProperty('target') && target == 'android') {
@ -84,7 +82,7 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
{{#java8}} {{#java8}}
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
@ -95,9 +93,12 @@ if(hasProperty('target') && target == 'android') {
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
{{/java8}} {{/java8}}
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -9,12 +9,11 @@
#define {{apiHeaderGuardPrefix}}_{{classname}}_H_ #define {{apiHeaderGuardPrefix}}_{{classname}}_H_
{{{defaultInclude}}} {{{defaultInclude}}}
#include "../ApiClient.h"
#include "ApiClient.h"
{{^hasModelImport}}#include "ModelBase.h"{{/hasModelImport}}
{{#imports}}{{{import}}} {{#imports}}{{{import}}}
{{/imports}} {{/imports}}
{{^hasModelImport}}#include "../ModelBase.h"{{/hasModelImport}}
#include <boost/optional.hpp> #include <boost/optional.hpp>
{{#apiNamespaceDeclarations}} {{#apiNamespaceDeclarations}}

View File

@ -0,0 +1,5 @@
@PACKAGE_INIT@
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)
check_required_components("@PROJECT_NAME@")

View File

@ -8,69 +8,85 @@
# #
# NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech). # NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech).
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 3.1)
#PROJECT's NAME project({{{packageName}}})
project(CppRestOpenAPIClient)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# THE LOCATION OF OUTPUT BINARIES set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/lib) set(CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
# BUILD TYPE find_package(cpprestsdk REQUIRED)
message("A ${CMAKE_BUILD_TYPE} build configuration is detected") find_package(Boost REQUIRED)
if (UNIX) include(GNUInstallDirs)
message(STATUS "Building client library for Linux/Unix") include(CMakePackageConfigHelpers)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Wno-unused-variable") file(GLOB_RECURSE HEADER_FILES "*.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-unused-variable") file(GLOB_RECURSE SOURCE_FILES "*.cpp")
set(cpprestsdk_DIR /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/cmake/)
find_package(cpprestsdk REQUIRED) add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
find_package(Boost REQUIRED)
else()
message(STATUS "Building client library for Windows")
find_package(cpprestsdk REQUIRED) target_compile_options(${PROJECT_NAME}
find_package(Boost REQUIRED) PRIVATE
endif() $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wno-unused-variable>
# Manually set the cpprestsdk paths when not using package manager
#set(CPPREST_INCLUDE_DIR ${CPPREST_ROOT}/include)
#set(CPPREST_LIBRARY_DIR ${CPPREST_ROOT}/lib)
#include_directories(${CPPREST_INCLUDE_DIR})
#link_directories(${CPPREST_LIBRARY_DIR})
#SUPPORTING FILES
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData" "Object")
#SOURCE FILES
file(GLOB SOURCE_FILES "api/*" "model/*")
add_library(${PROJECT_NAME} ${SUPPORTING_FILES} ${SOURCE_FILES})
target_include_directories(
${PROJECT_NAME} PRIVATE
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/model
${CMAKE_CURRENT_SOURCE_DIR}/api
) )
target_link_directories( target_include_directories(${PROJECT_NAME}
${PROJECT_NAME} PRIVATE PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_directories(${PROJECT_NAME}
PRIVATE
${Boost_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS}
) )
if (UNIX) if (UNIX)
target_link_libraries(${PROJECT_NAME} PRIVATE cpprest ${Boost_LIBRARIES} crypto) message(STATUS "Building client library for Linux/Unix")
target_link_libraries(${PROJECT_NAME} PUBLIC cpprest ${Boost_LIBRARIES} crypto)
else() else()
target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest ${Boost_LIBRARIES} bcrypt) message(STATUS "Building client library for Windows")
target_link_libraries(${PROJECT_NAME} PUBLIC cpprestsdk::cpprest ${Boost_LIBRARIES} bcrypt)
endif() endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.h"
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(
EXPORT ${PROJECT_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

View File

@ -10,7 +10,7 @@
{{^parent}} {{^parent}}
{{{defaultInclude}}} {{{defaultInclude}}}
#include "../ModelBase.h" #include "ModelBase.h"
{{/parent}} {{/parent}}
{{#imports}}{{{this}}} {{#imports}}{{{this}}}

View File

@ -1,39 +1,14 @@
# Generated by: https://openapi-generator.tech # Generated by: https://openapi-generator.tech
# #
*.gem /docs/
*.rbc /lib/
/.config /bin/
/coverage/ /.shards/
/InstalledFiles *.dwarf
/pkg/
/spec/reports/ # Libraries don't need dependency lock
/spec/examples.txt # Dependencies will be locked in applications that use them
/test/tmp/ /shard.lock
/test/version_tmp/
/tmp/ /tmp/
## Specific to RubyMotion:
.dat*
.repl_history
build/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

View File

@ -1,2 +0,0 @@
--color
--require spec_helper

View File

@ -1,148 +0,0 @@
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
# Automatically generated by OpenAPI Generator (https://openapi-generator.tech)
AllCops:
TargetRubyVersion: 2.4
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true
# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true
# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true
Layout/ElseAlignment:
Enabled: true
Layout/EmptyLineAfterMagicComment:
Enabled: true
# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true
# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true
# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/FirstArgumentIndentation:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: false
# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: indented_internal_methods
# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeComma:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true
Style/DefWithParentheses:
Enabled: true
# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: false
EnforcedStyle: always
# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true
# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideParens:
Enabled: true
# Check quotes usage according to lint rule below.
#Style/StringLiterals:
# Enabled: true
# EnforcedStyle: single_quotes
# Detect hard tabs, no hard tabs.
Layout/IndentationStyle:
Enabled: true
# Blank lines should not have any spaces.
Layout/TrailingEmptyLines:
Enabled: true
# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: false
# Use quotes for string literals when they are enough.
Style/RedundantPercentQ:
Enabled: true
# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
AutoCorrect: true
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true
Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true
Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true

View File

@ -106,7 +106,7 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
{{/isContainer}} {{/isContainer}}
{{#isModel}} {{#isModel}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
{{! These are models that have nee manually marked as primitve via generator param. }} {{! These are models that have nee manually marked as primitive via generator param. }}
result.{{{name}}} = valueDes; result.{{{name}}} = valueDes;
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{^isPrimitiveType}} {{^isPrimitiveType}}

View File

@ -2,8 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
maven { url = uri("https://repo1.maven.org/maven2") }
} }
dependencies { dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.0.M3") classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.0.M3")
@ -14,8 +13,7 @@ group = "{{groupId}}"
version = "{{artifactVersion}}" version = "{{artifactVersion}}"
repositories { repositories {
jcenter() mavenCentral()
maven { url = uri("https://repo1.maven.org/maven2") }
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {

View File

@ -56,9 +56,15 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
$HeaderParameters['Accept'] = $Accept $HeaderParameters['Accept'] = $Accept
} }
[string]$MultiPartBoundary = $null
$ContentType= SelectHeaders -Headers $ContentTypes $ContentType= SelectHeaders -Headers $ContentTypes
if ($ContentType) { if ($ContentType) {
$HeaderParameters['Content-Type'] = $ContentType $HeaderParameters['Content-Type'] = $ContentType
if ($ContentType -eq 'multipart/form-data') {
[string]$MultiPartBoundary = [System.Guid]::NewGuid()
$MultiPartBoundary = "---------------------------$MultiPartBoundary"
$HeaderParameters['Content-Type'] = "$ContentType; boundary=$MultiPartBoundary"
}
} }
# add default headers if any # add default headers if any
@ -66,7 +72,6 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
$HeaderParameters[$header.Name] = $header.Value $HeaderParameters[$header.Name] = $header.Value
} }
# construct URL query string # construct URL query string
$HttpValues = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) $HttpValues = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
foreach ($Parameter in $QueryParameters.GetEnumerator()) { foreach ($Parameter in $QueryParameters.GetEnumerator()) {
@ -84,8 +89,33 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
# include form parameters in the request body # include form parameters in the request body
if ($FormParameters -and $FormParameters.Count -gt 0) { if ($FormParameters -and $FormParameters.Count -gt 0) {
if (![string]::IsNullOrEmpty($MultiPartBoundary)) {
$RequestBody = ""
$LF = "`r`n"
$FormParameters.Keys | ForEach-Object {
$value = $FormParameters[$_]
$isFile = $value.GetType().FullName -eq "System.IO.FileInfo"
$RequestBody += "--$MultiPartBoundary$LF"
$RequestBody += "Content-Disposition: form-data; name=`"$_`""
if ($isFile) {
$fileName = $value.Name
$RequestBody += "; filename=`"$fileName`"$LF"
$RequestBody += "Content-Type: application/octet-stream$LF$LF"
$RequestBody += Get-Content -Path $value.FullName
} else {
$RequestBody += "$LF$LF"
$RequestBody += ([string]$value)
}
$RequestBody += "$LF--$MultiPartBoundary"
}
$RequestBody += "--"
} else {
$RequestBody = $FormParameters $RequestBody = $FormParameters
} }
}
if ($Body -or $IsBodyNullable) { if ($Body -or $IsBodyNullable) {
$RequestBody = $Body $RequestBody = $Body

View File

@ -278,6 +278,9 @@ conf = {{{packageName}}}.Configuration(
self.proxy = None self.proxy = None
"""Proxy URL """Proxy URL
""" """
self.no_proxy = None
"""bypass proxy for host in the no_proxy list.
"""
self.proxy_headers = None self.proxy_headers = None
"""Proxy headers """Proxy headers
""" """

View File

@ -6,8 +6,10 @@ import logging
import re import re
import ssl import ssl
from urllib.parse import urlencode from urllib.parse import urlencode
from urllib.parse import urlparse
from urllib.request import proxy_bypass_environment
import urllib3 import urllib3
import ipaddress
from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError
@ -64,7 +66,7 @@ class RESTClientObject(object):
maxsize = 4 maxsize = 4
# https pool manager # https pool manager
if configuration.proxy: if configuration.proxy and not should_bypass_proxies(configuration.host, no_proxy=configuration.no_proxy or ''):
self.pool_manager = urllib3.ProxyManager( self.pool_manager = urllib3.ProxyManager(
num_pools=pools_size, num_pools=pools_size,
maxsize=maxsize, maxsize=maxsize,
@ -282,3 +284,55 @@ class RESTClientObject(object):
_preload_content=_preload_content, _preload_content=_preload_content,
_request_timeout=_request_timeout, _request_timeout=_request_timeout,
body=body) body=body)
# end of class RESTClientObject
def is_ipv4(target):
""" Test if IPv4 address or not
"""
try:
chk = ipaddress.IPv4Address(target)
return True
except ipaddress.AddressValueError:
return False
def in_ipv4net(target, net):
""" Test if target belongs to given IPv4 network
"""
try:
nw = ipaddress.IPv4Network(net)
ip = ipaddress.IPv4Address(target)
if ip in nw:
return True
return False
except ipaddress.AddressValueError:
return False
except ipaddress.NetmaskValueError:
return False
def should_bypass_proxies(url, no_proxy=None):
""" Yet another requests.should_bypass_proxies
Test if proxies should not be used for a particular url.
"""
parsed = urlparse(url)
# special cases
if parsed.hostname in [None, '']:
return True
# special cases
if no_proxy in [None , '']:
return False
if no_proxy == '*':
return True
no_proxy = no_proxy.lower().replace(' ','');
entries = (
host for host in no_proxy.split(',') if host
)
if is_ipv4(parsed.hostname):
for item in entries:
if in_ipv4net(parsed.hostname, item):
return True
return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} )

View File

@ -6,7 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.+' classpath 'com.android.tools.build:gradle:1.5.+'
@ -15,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,14 +77,17 @@ if(hasProperty('target') && target == 'android') {
apply plugin: 'scala' apply plugin: 'scala'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

View File

@ -9,9 +9,11 @@ import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
{{#imports}} {{#imports}}
import { {{classname}} } from '../model/models'; // @ts-ignore
import { {{ classname }} } from '{{ filename }}';
{{/imports}} {{/imports}}
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { {{configurationClassName}} } from '../configuration'; import { {{configurationClassName}} } from '../configuration';
{{#withInterfaces}} {{#withInterfaces}}

View File

@ -337,7 +337,7 @@ export class {{classname}} extends runtime.BaseAPI {
return await response.value(); return await response.value();
{{/returnType}} {{/returnType}}
{{^returnType}} {{^returnType}}
await this.{{nickname}}Raw({{#allParams.0}}{ {{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}} }{{/allParams.0}}, initOverrides); await this.{{nickname}}Raw({{#allParams.0}}{ {{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}} }, {{/allParams.0}}initOverrides);
{{/returnType}} {{/returnType}}
} }
{{/useSingleRequestParameter}} {{/useSingleRequestParameter}}

View File

@ -96,7 +96,17 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname
(apiObject as any).recType = {{#isEntity}}asEntity ? {{classname}}RecordEntityProps.recType : {{/isEntity}}{{classname}}RecordProps.recType; (apiObject as any).recType = {{#isEntity}}asEntity ? {{classname}}RecordEntityProps.recType : {{/isEntity}}{{classname}}RecordProps.recType;
{{#vars}} {{#vars}}
{{#isUniqueId}} {{#isUniqueId}}
{{^required}}if (apiObject.{{name}}) { {{/required}}(apiObject as any).{{name}} = apiObject.{{name}}.{{#isArray}}map(item => item.{{/isArray}}toString(){{#isArray}}){{/isArray}};{{^required}} } {{/required}} {{#isArray}}
{{#items.isArray}}
{{^required}}if (apiObject.{{name}}) { {{/required}}(apiObject as any).{{name}} = apiObject.{{name}}.map(item => item.map(item2 => item2?.toString()));{{^required}} } {{/required}}
{{/items.isArray}}
{{^items.isArray}}
{{^required}}if (apiObject.{{name}}) { {{/required}}(apiObject as any).{{name}} = apiObject.{{name}}.map(item => item?.toString());{{^required}} } {{/required}}
{{/items.isArray}}
{{/isArray}}
{{^isArray}}
{{^required}}if (apiObject.{{name}}) { {{/required}}(apiObject as any).{{name}} = apiObject.{{name}}.toString();{{^required}} } {{/required}}
{{/isArray}}
{{/isUniqueId}} {{/isUniqueId}}
{{^keepAsJSObject}} {{^keepAsJSObject}}
{{#isModel}} {{#isModel}}
@ -134,6 +144,7 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname
public *toInlined(entityId?: string | null) { public *toInlined(entityId?: string | null) {
if (!entityId) {return undefined; } if (!entityId) {return undefined; }
// @ts-ignore
const entity = yield select(apiEntity{{classname}}Selector, {id: entityId}); const entity = yield select(apiEntity{{classname}}Selector, {id: entityId});
if (!entity) {return undefined; } if (!entity) {return undefined; }
@ -160,12 +171,14 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname
{{#vars}} {{#vars}}
{{#isEntity}} {{#isEntity}}
{{^keepAsJSObject}} {{^keepAsJSObject}}
// @ts-ignore
{{name}}: {{^required}}entity.{{name}} ? {{/required}}yield call({{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.toInlined, entity.{{name}}){{^required}} : null{{/required}}, {{name}}: {{^required}}entity.{{name}} ? {{/required}}yield call({{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.toInlined, entity.{{name}}){{^required}} : null{{/required}},
{{/keepAsJSObject}} {{/keepAsJSObject}}
{{/isEntity}} {{/isEntity}}
{{#isArray}} {{#isArray}}
{{#items.isEntity}} {{#items.isEntity}}
{{^keepAsJSObject}} {{^keepAsJSObject}}
// @ts-ignore
{{name}}: {{^required}}entity.{{name}} ? {{/required}}yield call({{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.toInlinedArray, entity.{{name}}){{^required}} : null{{/required}}, {{name}}: {{^required}}entity.{{name}} ? {{/required}}yield call({{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.toInlinedArray, entity.{{name}}){{^required}} : null{{/required}},
{{/keepAsJSObject}} {{/keepAsJSObject}}
{{/items.isEntity}} {{/items.isEntity}}
@ -183,6 +196,7 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname
if (!entityIds) {return null; } if (!entityIds) {return null; }
let entities = List<{{classname}}Record>(); let entities = List<{{classname}}Record>();
for (let entityIndex = 0; entityIndex < entityIds.count(); entityIndex++) { for (let entityIndex = 0; entityIndex < entityIds.count(); entityIndex++) {
// @ts-ignore
const entity = yield call(this.toInlined, entityIds.get(entityIndex)); const entity = yield call(this.toInlined, entityIds.get(entityIndex));
if (entity) { if (entity) {
entities.push(entity); entities.push(entity);
@ -196,7 +210,17 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname
const apiObject = super.toApi(record); const apiObject = super.toApi(record);
{{#vars}} {{#vars}}
{{#isUniqueId}} {{#isUniqueId}}
{{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{#isArray}}record.{{name}}.map(item => parseFloat(item)).toArray(){{/isArray}}{{^isArray}}parseFloat(record.{{name}}){{/isArray}};{{^required}} } {{/required}} {{#isArray}}
{{#items.isArray}}
{{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{#isArray}}record.{{name}}.map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(){{/isArray}};{{^required}} } {{/required}}
{{/items.isArray}}
{{^items.isArray}}
{{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{#isArray}}record.{{name}}.map(item => (item ? parseFloat(item) : null) as number).toArray(){{/isArray}};{{^required}} } {{/required}}
{{/items.isArray}}
{{/isArray}}
{{^isArray}}
{{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{^isArray}}parseFloat(record.{{name}}){{/isArray}};{{^required}} } {{/required}}
{{/isArray}}
{{/isUniqueId}} {{/isUniqueId}}
{{^keepAsJSObject}} {{^keepAsJSObject}}
{{#isModel}} {{#isModel}}

View File

@ -18,15 +18,7 @@ export class Api {
{{/apis}} {{/apis}}
{{/apiInfo}} {{/apiInfo}}
public static init(apiBasePath: string) { public static init(apiBaseConfig: ConfigurationParameters) {
const apiBaseConfig: ConfigurationParameters = {
basePath: apiBasePath,
credentials: "include",
headers: {
'Cache-Control': 'no-cache, no-store' // this is needed to prevent stalling issues in Chrome. Also it is a good behavior for api calls.
}
};
{{#apiInfo}} {{#apiInfo}}
{{#apis}} {{#apis}}
Api.{{#lambda.camelcase}}{{classFilename}}{{/lambda.camelcase}} = new {{classFilename}}(new Configuration(apiBaseConfig)); Api.{{#lambda.camelcase}}{{classFilename}}{{/lambda.camelcase}} = new {{classFilename}}(new Configuration(apiBaseConfig));

View File

@ -105,12 +105,17 @@ export function *{{nickname}}SagaImp(_action_: Action<Payload{{#lambda.titlecase
yield put({{nickname}}Request({{#allParams.0}}{{#returnTypeSupportsEntities}}requestPayload{{/returnTypeSupportsEntities}}{{^returnTypeSupportsEntities}}_action_.payload{{/returnTypeSupportsEntities}}{{/allParams.0}})); yield put({{nickname}}Request({{#allParams.0}}{{#returnTypeSupportsEntities}}requestPayload{{/returnTypeSupportsEntities}}{{^returnTypeSupportsEntities}}_action_.payload{{/returnTypeSupportsEntities}}{{/allParams.0}}));
const response{{#returnType}}: Required<{{{.}}}>{{/returnType}} = yield apiCall(Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}, Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}.{{nickname}}, const response{{#returnType}}: Required<{{{returnType}}}>{{/returnType}} = yield apiCall(Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}, Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}.{{nickname}},
{{#allParams.0}} {{#allParams.0}}
{{#allParams}} {{#allParams}}
{{#isUniqueId}} {{#isUniqueId}}
{{#isArray}} {{#isArray}}
{{^required}}{{paramName}} ? {{/required}}{{paramName}}.map(p => parseFloat(p)).toArray(){{^required}} : undefined{{/required}}, {{#items.isArray}}
{{^required}}{{paramName}} ? {{/required}}{{paramName}}.map(p => p.toArray().map(p2 => (p2 ? parseFloat(p2) : null) as number)).toArray(){{^required}} : undefined{{/required}},
{{/items.isArray}}
{{^items.isArray}}
{{^required}}{{paramName}} ? {{/required}}{{paramName}}.map(p => (p ? parseFloat(p) : null) as number ).toArray(){{^required}} : undefined{{/required}},
{{/items.isArray}}
{{/isArray}} {{/isArray}}
{{^isArray}} {{^isArray}}
{{^required}}{{paramName}} ? {{/required}}parseFloat({{paramName}}){{^required}} : undefined{{/required}}, {{^required}}{{paramName}} ? {{/required}}parseFloat({{paramName}}){{^required}} : undefined{{/required}},

View File

@ -285,7 +285,7 @@ public class KotlinSpringServerCodegenTest {
generator.opts(input).generate(); generator.opts(input).generate();
assertFileNotContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PonyApi.kt"), "@RequestParam"); assertFileNotContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PonyApiController.kt"), "@RequestParam");
} }
@Test @Test
@ -315,14 +315,14 @@ public class KotlinSpringServerCodegenTest {
generator.opts(input).generate(); generator.opts(input).generate();
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/MonkeysApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/MonkeysApiController.kt"), "@RequestParam");
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ElephantsApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ElephantsApiController.kt"), "@RequestParam");
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ZebrasApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ZebrasApiController.kt"), "@RequestParam");
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/BearsApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/BearsApiController.kt"), "@RequestParam");
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/CamelsApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/CamelsApiController.kt"), "@RequestParam");
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PandasApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PandasApiController.kt"), "@RequestParam");
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/CrocodilesApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/CrocodilesApiController.kt"), "@RequestParam");
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PolarBearsApi.kt"), "@RequestParam"); assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PolarBearsApiController.kt"), "@RequestParam");
} }
@Test @Test
@ -352,11 +352,11 @@ public class KotlinSpringServerCodegenTest {
generator.opts(input).generate(); generator.opts(input).generate();
assertFileContains( assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ElephantsApi.kt"), Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ElephantsApiController.kt"),
"@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)" "@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)"
); );
assertFileContains( assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ZebrasApi.kt"), Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/ZebrasApiController.kt"),
"@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME)" "@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME)"
); );
} }

View File

@ -29,6 +29,7 @@ import io.swagger.v3.parser.util.SchemaTypeUtil;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -464,4 +465,26 @@ public class PythonClientTest {
} }
@Test(description = "tests NoProxyPyClient")
public void testNoProxyPyClient() throws Exception {
final String gen = "python";
final String spec = "src/test/resources/3_0/petstore.yaml";
File output = Files.createTempDirectory("test").toFile();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName(gen)
.setInputSpec(spec)
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
List<File> files = generator.opts(clientOptInput).generate();
for (String f : new String[] { "openapi_client/configuration.py", "openapi_client/rest.py" } ) {
TestUtils.ensureContainsFile(files, output, f);
Path p = output.toPath().resolve(f);
TestUtils.assertFileContains(p, "no_proxy");
}
}
} }

View File

@ -228,7 +228,7 @@ public class TypeScriptAngularClientCodegenTest {
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("test", schema); OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("test", schema);
codegen.setOpenAPI(openAPI); codegen.setOpenAPI(openAPI);
Assert.assertEquals(codegen.toModelImport(modelName), "model/foo-response-links"); Assert.assertEquals(codegen.toModelImport(modelName), "../model/foo-response-links");
Assert.assertEquals(codegen.toModelFilename(modelName), "./foo-response-links"); Assert.assertEquals(codegen.toModelFilename(modelName), "./foo-response-links");
} }
@ -258,4 +258,13 @@ public class TypeScriptAngularClientCodegenTest {
Assert.assertEquals(codegen.toParamName("valid_id"), "ValidId"); Assert.assertEquals(codegen.toParamName("valid_id"), "ValidId");
Assert.assertEquals(codegen.toParamName("illegal-id+"), "IllegalId"); Assert.assertEquals(codegen.toParamName("illegal-id+"), "IllegalId");
} }
@Test
public void testCorrectlyProducesImportsWithImportMapping() {
TypeScriptAngularClientCodegen codegen = new TypeScriptAngularClientCodegen();
final String importedModel = "SharedApiModel";
final String importName = "@lib/custom/model";
codegen.importMapping().put(importedModel, importName);
Assert.assertEquals(codegen.toModelImport(importedModel), importName);
}
} }

View File

@ -295,6 +295,46 @@ paths:
- 'write:pets' - 'write:pets'
- 'read:pets' - 'read:pets'
deprecated: true deprecated: true
'/pet/{petId}/regions':
get:
tags:
- pet
summary: Gets regions for a single pet.
operationId: getPetRegions
parameters:
- name: petId
in: path
description: ID of pet
required: true
type: integer
format: int64
responses:
200:
description: OK
schema:
$ref: "#/definitions/PetRegionsResponse"
put:
tags:
- pet
summary: Updates the pet regions.
operationId: updatePetRegions
parameters:
- name: petId
in: path
description: ID of pet
required: true
type: integer
format: int64
- in: body
name: new-regions
required: true
schema:
$ref: "#/definitions/PetRegions"
responses:
200:
description: OK
schema:
$ref: "#/definitions/PetRegionsResponse"
'/pet/{petId}': '/pet/{petId}':
get: get:
tags: tags:
@ -902,6 +942,8 @@ definitions:
- pending - pending
- sold - sold
default: pending default: pending
regions:
$ref: "#/definitions/PetRegions"
xml: xml:
name: Pet name: Pet
ApiResponse: ApiResponse:
@ -1127,6 +1169,15 @@ definitions:
- Long - Long
description: "Type of pet part" description: "Type of pet part"
example: Linear example: Linear
PetRegionsResponse:
type: object
required:
- meta
properties:
meta:
$ref: "#/definitions/ResponseMeta"
data:
$ref: "#/definitions/PetRegions"
GetMatchingPartsResponse: GetMatchingPartsResponse:
type: object type: object
required: required:
@ -1173,3 +1224,14 @@ definitions:
StringBooleanMap: StringBooleanMap:
additionalProperties: additionalProperties:
type: boolean type: boolean
PetRegions:
type: array
description: "An array of all 15-minute time slots in 24 hours."
items:
type: array
items:
description: "array of values entity id or null."
x-nullable: true
x-isUniqueId: true
type: integer
format: int64

View File

@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -83,7 +82,7 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
{{#java8}} {{#java8}}
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
@ -93,9 +92,12 @@ if(hasProperty('target') && target == 'android') {
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
{{/java8}} {{/java8}}
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = '{{artifactId}}' maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
} }
} }

70
pom.xml
View File

@ -1172,7 +1172,6 @@
</property> </property>
</activation> </activation>
<modules> <modules>
<module>samples/server/petstore/kotlin-springboot</module>
<module>samples/server/petstore/jaxrs/jersey2</module> <module>samples/server/petstore/jaxrs/jersey2</module>
<module>samples/server/petstore/jaxrs/jersey2-useTags</module> <module>samples/server/petstore/jaxrs/jersey2-useTags</module>
<module>samples/server/petstore/spring-mvc</module> <module>samples/server/petstore/spring-mvc</module>
@ -1230,7 +1229,6 @@
<module>samples/server/petstore/scala-akka-http-server</module> <module>samples/server/petstore/scala-akka-http-server</module>
<module>samples/server/petstore/scalatra</module> <module>samples/server/petstore/scalatra</module>
<module>samples/server/petstore/scala-finch</module> <module>samples/server/petstore/scala-finch</module>
<!--<module>samples/server/petstore/kotlin/vertx</module>-->
</modules> </modules>
</profile> </profile>
<!-- node 3 tests in CircleCI --> <!-- node 3 tests in CircleCI -->
@ -1247,6 +1245,33 @@
<module>samples/client/petstore/python</module> <module>samples/client/petstore/python</module>
<module>samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent</module> <module>samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent</module>
<module>samples/openapi3/client/petstore/python</module> <module>samples/openapi3/client/petstore/python</module>
<!-- TODO comment out below when the test for typescript-nestjs is ready
<module>samples/client/petstore/typescript-nestjs-v6-provided-in-root</module>-->
<!-- comment out due to error `npm run build`
<module>samples/client/petstore/typescript-jquery/npm</module>-->
<module>samples/client/petstore/typescript-angular-v7-provided-in-root</module>
<module>samples/client/petstore/typescript-angular-v11-provided-in-root</module>
<module>samples/openapi3/client/petstore/typescript/builds/default</module>
<module>samples/openapi3/client/petstore/typescript/tests/default</module>
<module>samples/openapi3/client/petstore/typescript/builds/jquery</module>
<module>samples/openapi3/client/petstore/typescript/tests/jquery</module>
<module>samples/openapi3/client/petstore/typescript/builds/object_params</module>
<module>samples/openapi3/client/petstore/typescript/tests/object_params</module>
<module>samples/openapi3/client/petstore/typescript/builds/inversify</module>
<!-- comment out due to failure in travis ci
<module>samples/openapi3/client/petstore/typescript/tests/inversify</module>
<module>samples/openapi3/client/petstore/typescript/tests/deno</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>
<module>samples/client/petstore/typescript-fetch/tests/default</module>
<module>samples/client/petstore/typescript-node/npm</module>
<module>samples/client/petstore/typescript-rxjs/builds/with-npm-version</module>
<module>samples/client/petstore/typescript-axios/builds/with-npm-version</module>
<module>samples/client/petstore/typescript-axios/tests/default</module>
<module>samples/client/petstore/javascript-flowtyped</module>
<module>samples/client/petstore/javascript-es6</module>
<module>samples/client/petstore/javascript-promise-es6</module>
</modules> </modules>
</profile> </profile>
<!-- other tests in CircleCI --> <!-- other tests in CircleCI -->
@ -1290,39 +1315,6 @@
<module>samples/client/petstore/java/microprofile-rest-client</module> <module>samples/client/petstore/java/microprofile-rest-client</module>
<module>samples/client/petstore/java/apache-httpclient</module> <module>samples/client/petstore/java/apache-httpclient</module>
<module>samples/client/petstore/groovy</module> <module>samples/client/petstore/groovy</module>
<!-- test non-java projects -->
<module>samples/client/petstore/go</module>
<module>samples/openapi3/client/petstore/go</module>
<module>samples/client/petstore/javascript-flowtyped</module>
<module>samples/client/petstore/javascript-es6</module>
<module>samples/client/petstore/javascript-promise-es6</module>
<module>samples/server/petstore/go-api-server</module>
<module>samples/server/petstore/go-gin-api-server</module>
<module>samples/server/petstore/go-echo-server</module>
<!-- TODO comment out below when the test for typescript-nestjs is ready
<module>samples/client/petstore/typescript-nestjs-v6-provided-in-root</module>-->
<!-- comment out due to error `npm run build`
<module>samples/client/petstore/typescript-jquery/npm</module>-->
<module>samples/client/petstore/typescript-angular-v7-provided-in-root</module>
<module>samples/client/petstore/typescript-angular-v11-provided-in-root</module>
<module>samples/openapi3/client/petstore/typescript/builds/default</module>
<module>samples/openapi3/client/petstore/typescript/tests/default</module>
<module>samples/openapi3/client/petstore/typescript/builds/jquery</module>
<module>samples/openapi3/client/petstore/typescript/tests/jquery</module>
<module>samples/openapi3/client/petstore/typescript/builds/object_params</module>
<module>samples/openapi3/client/petstore/typescript/tests/object_params</module>
<module>samples/openapi3/client/petstore/typescript/builds/inversify</module>
<!-- comment out due to failure in travis ci
<module>samples/openapi3/client/petstore/typescript/tests/inversify</module>
<module>samples/openapi3/client/petstore/typescript/tests/deno</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>
<module>samples/client/petstore/typescript-fetch/tests/default</module>
<module>samples/client/petstore/typescript-node/npm</module>
<module>samples/client/petstore/typescript-rxjs/builds/with-npm-version</module>
<module>samples/client/petstore/typescript-axios/builds/with-npm-version</module>
<module>samples/client/petstore/typescript-axios/tests/default</module>
</modules> </modules>
</profile> </profile>
<!-- test with JDK9 in Shippable CI --> <!-- test with JDK9 in Shippable CI -->
@ -1356,6 +1348,8 @@
<module>samples/client/petstore/kotlin-threetenbp</module> <module>samples/client/petstore/kotlin-threetenbp</module>
<module>samples/client/petstore/kotlin-uppercase-enum</module> <module>samples/client/petstore/kotlin-uppercase-enum</module>
<!-- servers --> <!-- servers -->
<module>samples/server/petstore/kotlin-springboot</module>
<!--<module>samples/server/petstore/kotlin/vertx</module>-->
<!--<module>samples/server/petstore/erlang-server</module>--> <!--<module>samples/server/petstore/erlang-server</module>-->
</modules> </modules>
</profile> </profile>
@ -1388,6 +1382,12 @@
<!--<module>samples/client/petstore/haskell-http-client</module>--> <!--<module>samples/client/petstore/haskell-http-client</module>-->
<!-- servers --> <!-- servers -->
<!--<module>samples/server/petstore/haskell-servant</module>--> <!--<module>samples/server/petstore/haskell-servant</module>-->
<!-- test Go projects -->
<module>samples/client/petstore/go</module>
<module>samples/openapi3/client/petstore/go</module>
<module>samples/server/petstore/go-api-server</module>
<module>samples/server/petstore/go-gin-api-server</module>
<module>samples/server/petstore/go-echo-server</module>
</modules> </modules>
</profile> </profile>
<profile> <profile>

View File

@ -13,7 +13,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
Building the API client library requires: Building the API client library requires:
1. Java 1.7+ 1. Java 1.7+
2. Maven/Gradle 2. Maven (3.8.3+)/Gradle (7.2+)
## Installation ## Installation
@ -49,7 +49,14 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file: Add this dependency to your project's build file:
```groovy ```groovy
compile "org.openapitools:petstore-okhttp-gson:1.0" repositories {
mavenCentral() // Needed if the 'petstore-okhttp-gson' jar has been published to maven central.
mavenLocal() // Needed if the 'petstore-okhttp-gson' jar has been published to the local maven repo.
}
dependencies {
implementation "org.openapitools:petstore-okhttp-gson:1.0"
}
``` ```
### Others ### Others

View File

@ -50,7 +50,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version> <version>3.0.0</version>
<executions> <executions>
<execution> <execution>
<id>enforce-maven</id> <id>enforce-maven</id>
@ -70,7 +70,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version> <version>3.0.0-M5</version>
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
@ -97,16 +97,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- attach test jar --> <!-- attach test jar -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.2</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>jar</goal>
<goal>test-jar</goal> <goal>test-jar</goal>
</goals> </goals>
</execution> </execution>
@ -114,11 +112,10 @@
<configuration> <configuration>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>add_sources</id> <id>add_sources</id>
@ -149,7 +146,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<id>attach-javadocs</id> <id>attach-javadocs</id>
@ -172,7 +169,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
@ -193,7 +190,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId> <artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version> <version>3.0.1</version>
<executions> <executions>
<execution> <execution>
<id>sign-artifacts</id> <id>sign-artifacts</id>
@ -272,23 +269,23 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>3.11.2</version> <version>3.12.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>
<java.version>1.7</java.version> <java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.8.5</gson-fire-version> <gson-fire-version>1.8.5</gson-fire-version>
<swagger-core-version>1.6.2</swagger-core-version> <swagger-core-version>1.6.3</swagger-core-version>
<okhttp-version>4.9.1</okhttp-version> <okhttp-version>4.9.2</okhttp-version>
<gson-version>2.8.6</gson-version> <gson-version>2.8.8</gson-version>
<commons-lang3-version>3.11</commons-lang3-version> <commons-lang3-version>3.12.0</commons-lang3-version>
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version> <jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version>
<threetenbp-version>1.5.0</threetenbp-version> <threetenbp-version>1.5.0</threetenbp-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version> <jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>4.13.1</junit-version> <junit-version>4.13.2</junit-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
</project> </project>

View File

@ -54,6 +54,9 @@ import org.openapitools.client.auth.HttpBasicAuth;
import org.openapitools.client.auth.HttpBearerAuth; import org.openapitools.client.auth.HttpBearerAuth;
import org.openapitools.client.auth.ApiKeyAuth; import org.openapitools.client.auth.ApiKeyAuth;
/**
* <p>ApiClient class.</p>
*/
public class ApiClient { public class ApiClient {
private String basePath = "http://localhost:8082"; private String basePath = "http://localhost:8082";
@ -78,7 +81,7 @@ public class ApiClient {
private HttpLoggingInterceptor loggingInterceptor; private HttpLoggingInterceptor loggingInterceptor;
/* /**
* Basic constructor for ApiClient * Basic constructor for ApiClient
*/ */
public ApiClient() { public ApiClient() {
@ -90,8 +93,10 @@ public class ApiClient {
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
} }
/* /**
* Basic constructor with custom OkHttpClient * Basic constructor with custom OkHttpClient
*
* @param client a {@link okhttp3.OkHttpClient} object
*/ */
public ApiClient(OkHttpClient client) { public ApiClient(OkHttpClient client) {
init(); init();
@ -162,7 +167,7 @@ public class ApiClient {
* *
* @param newHttpClient An instance of OkHttpClient * @param newHttpClient An instance of OkHttpClient
* @return Api Client * @return Api Client
* @throws NullPointerException when newHttpClient is null * @throws java.lang.NullPointerException when newHttpClient is null
*/ */
public ApiClient setHttpClient(OkHttpClient newHttpClient) { public ApiClient setHttpClient(OkHttpClient newHttpClient) {
this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!");
@ -234,6 +239,11 @@ public class ApiClient {
return this; return this;
} }
/**
* <p>Getter for the field <code>keyManagers</code>.</p>
*
* @return an array of {@link javax.net.ssl.KeyManager} objects
*/
public KeyManager[] getKeyManagers() { public KeyManager[] getKeyManagers() {
return keyManagers; return keyManagers;
} }
@ -251,30 +261,65 @@ public class ApiClient {
return this; return this;
} }
/**
* <p>Getter for the field <code>dateFormat</code>.</p>
*
* @return a {@link java.text.DateFormat} object
*/
public DateFormat getDateFormat() { public DateFormat getDateFormat() {
return dateFormat; return dateFormat;
} }
/**
* <p>Setter for the field <code>dateFormat</code>.</p>
*
* @param dateFormat a {@link java.text.DateFormat} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setDateFormat(DateFormat dateFormat) { public ApiClient setDateFormat(DateFormat dateFormat) {
this.json.setDateFormat(dateFormat); this.json.setDateFormat(dateFormat);
return this; return this;
} }
/**
* <p>Set SqlDateFormat.</p>
*
* @param dateFormat a {@link java.text.DateFormat} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setSqlDateFormat(DateFormat dateFormat) { public ApiClient setSqlDateFormat(DateFormat dateFormat) {
this.json.setSqlDateFormat(dateFormat); this.json.setSqlDateFormat(dateFormat);
return this; return this;
} }
/**
* <p>Set OffsetDateTimeFormat.</p>
*
* @param dateFormat a {@link org.threeten.bp.format.DateTimeFormatter} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
this.json.setOffsetDateTimeFormat(dateFormat); this.json.setOffsetDateTimeFormat(dateFormat);
return this; return this;
} }
/**
* <p>Set LocalDateFormat.</p>
*
* @param dateFormat a {@link org.threeten.bp.format.DateTimeFormatter} object
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
this.json.setLocalDateFormat(dateFormat); this.json.setLocalDateFormat(dateFormat);
return this; return this;
} }
/**
* <p>Set LenientOnJson.</p>
*
* @param lenientOnJson a boolean
* @return a {@link org.openapitools.client.ApiClient} object
*/
public ApiClient setLenientOnJson(boolean lenientOnJson) { public ApiClient setLenientOnJson(boolean lenientOnJson) {
this.json.setLenientOnJson(lenientOnJson); this.json.setLenientOnJson(lenientOnJson);
return this; return this;
@ -471,7 +516,7 @@ public class ApiClient {
/** /**
* Sets the connect timeout (in milliseconds). * Sets the connect timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}. * {@link java.lang.Integer#MAX_VALUE}.
* *
* @param connectionTimeout connection timeout in milliseconds * @param connectionTimeout connection timeout in milliseconds
* @return Api client * @return Api client
@ -493,7 +538,7 @@ public class ApiClient {
/** /**
* Sets the read timeout (in milliseconds). * Sets the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}. * {@link java.lang.Integer#MAX_VALUE}.
* *
* @param readTimeout read timeout in milliseconds * @param readTimeout read timeout in milliseconds
* @return Api client * @return Api client
@ -515,7 +560,7 @@ public class ApiClient {
/** /**
* Sets the write timeout (in milliseconds). * Sets the write timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}. * {@link java.lang.Integer#MAX_VALUE}.
* *
* @param writeTimeout connection timeout in milliseconds * @param writeTimeout connection timeout in milliseconds
* @return Api client * @return Api client
@ -749,7 +794,7 @@ public class ApiClient {
* @param response HTTP response * @param response HTTP response
* @param returnType The type of the Java object * @param returnType The type of the Java object
* @return The deserialized Java object * @return The deserialized Java object
* @throws ApiException If fail to deserialize response body, i.e. cannot read response body * @throws org.openapitools.client.ApiException If fail to deserialize response body, i.e. cannot read response body
* or the Content-Type of the response is not supported. * or the Content-Type of the response is not supported.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -810,7 +855,7 @@ public class ApiClient {
* @param obj The Java object * @param obj The Java object
* @param contentType The request Content-Type * @param contentType The request Content-Type
* @return The serialized request body * @return The serialized request body
* @throws ApiException If fail to serialize the given object * @throws org.openapitools.client.ApiException If fail to serialize the given object
*/ */
public RequestBody serialize(Object obj, String contentType) throws ApiException { public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) { if (obj instanceof byte[]) {
@ -836,7 +881,7 @@ public class ApiClient {
* Download file from the given response. * Download file from the given response.
* *
* @param response An instance of the Response object * @param response An instance of the Response object
* @throws ApiException If fail to read file content from response and write to disk * @throws org.openapitools.client.ApiException If fail to read file content from response and write to disk
* @return Downloaded file * @return Downloaded file
*/ */
public File downloadFileFromResponse(Response response) throws ApiException { public File downloadFileFromResponse(Response response) throws ApiException {
@ -856,7 +901,7 @@ public class ApiClient {
* *
* @param response An instance of the Response object * @param response An instance of the Response object
* @return Prepared file for the download * @return Prepared file for the download
* @throws IOException If fail to prepare file for download * @throws java.io.IOException If fail to prepare file for download
*/ */
public File prepareDownloadFile(Response response) throws IOException { public File prepareDownloadFile(Response response) throws IOException {
String filename = null; String filename = null;
@ -900,7 +945,7 @@ public class ApiClient {
* @param <T> Type * @param <T> Type
* @param call An instance of the Call object * @param call An instance of the Call object
* @return ApiResponse&lt;T&gt; * @return ApiResponse&lt;T&gt;
* @throws ApiException If fail to execute the call * @throws org.openapitools.client.ApiException If fail to execute the call
*/ */
public <T> ApiResponse<T> execute(Call call) throws ApiException { public <T> ApiResponse<T> execute(Call call) throws ApiException {
return execute(call, null); return execute(call, null);
@ -915,7 +960,7 @@ public class ApiClient {
* @return ApiResponse object containing response status, headers and * @return ApiResponse object containing response status, headers and
* data, which is a Java object deserialized from response body and would be null * data, which is a Java object deserialized from response body and would be null
* when returnType is null. * when returnType is null.
* @throws ApiException If fail to execute the call * @throws org.openapitools.client.ApiException If fail to execute the call
*/ */
public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException { public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
try { try {
@ -927,6 +972,14 @@ public class ApiClient {
} }
} }
/**
* <p>Execute stream.</p>
*
* @param call a {@link okhttp3.Call} object
* @param returnType a {@link java.lang.reflect.Type} object
* @return a {@link java.io.InputStream} object
* @throws org.openapitools.client.ApiException if any.
*/
public InputStream executeStream(Call call, Type returnType) throws ApiException { public InputStream executeStream(Call call, Type returnType) throws ApiException {
try { try {
Response response = call.execute(); Response response = call.execute();
@ -994,7 +1047,7 @@ public class ApiClient {
* @param response Response * @param response Response
* @param returnType Return type * @param returnType Return type
* @return Type * @return Type
* @throws ApiException If the response has an unsuccessful status code or * @throws org.openapitools.client.ApiException If the response has an unsuccessful status code or
* fail to deserialize the response body * fail to deserialize the response body
*/ */
public <T> T handleResponse(Response response, Type returnType) throws ApiException { public <T> T handleResponse(Response response, Type returnType) throws ApiException {
@ -1040,7 +1093,7 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param callback Callback for upload/download progress * @param callback Callback for upload/download progress
* @return The HTTP call * @return The HTTP call
* @throws ApiException If fail to serialize the request body object * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/ */
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException { public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
@ -1062,7 +1115,7 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param callback Callback for upload/download progress * @param callback Callback for upload/download progress
* @return The HTTP request * @return The HTTP request
* @throws ApiException If fail to serialize the request body object * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/ */
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException { public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);

View File

@ -16,22 +16,47 @@ package org.openapitools.client;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
/**
* <p>ApiException class.</p>
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ApiException extends Exception { public class ApiException extends Exception {
private int code = 0; private int code = 0;
private Map<String, List<String>> responseHeaders = null; private Map<String, List<String>> responseHeaders = null;
private String responseBody = null; private String responseBody = null;
/**
* <p>Constructor for ApiException.</p>
*/
public ApiException() {} public ApiException() {}
/**
* <p>Constructor for ApiException.</p>
*
* @param throwable a {@link java.lang.Throwable} object
*/
public ApiException(Throwable throwable) { public ApiException(Throwable throwable) {
super(throwable); super(throwable);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
*/
public ApiException(String message) { public ApiException(String message) {
super(message); super(message);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
* @param throwable a {@link java.lang.Throwable} object
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
super(message, throwable); super(message, throwable);
this.code = code; this.code = code;
@ -39,23 +64,60 @@ public class ApiException extends Exception {
this.responseBody = responseBody; this.responseBody = responseBody;
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
this(message, (Throwable) null, code, responseHeaders, responseBody); this(message, (Throwable) null, code, responseHeaders, responseBody);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param message the error message
* @param throwable a {@link java.lang.Throwable} object
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
*/
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) { public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
this(message, throwable, code, responseHeaders, null); this(message, throwable, code, responseHeaders, null);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param code HTTP status code
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
this((String) null, (Throwable) null, code, responseHeaders, responseBody); this((String) null, (Throwable) null, code, responseHeaders, responseBody);
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param code HTTP status code
* @param message a {@link java.lang.String} object
*/
public ApiException(int code, String message) { public ApiException(int code, String message) {
super(message); super(message);
this.code = code; this.code = code;
} }
/**
* <p>Constructor for ApiException.</p>
*
* @param code HTTP status code
* @param message the error message
* @param responseHeaders a {@link java.util.Map} of HTTP response headers
* @param responseBody the response body
*/
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) { public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
this(code, message); this(code, message);
this.responseHeaders = responseHeaders; this.responseHeaders = responseHeaders;

View File

@ -18,8 +18,6 @@ import java.util.Map;
/** /**
* API response returned by API call. * API response returned by API call.
*
* @param <T> The type of data that is deserialized from response body
*/ */
public class ApiResponse<T> { public class ApiResponse<T> {
final private int statusCode; final private int statusCode;
@ -27,6 +25,8 @@ public class ApiResponse<T> {
final private T data; final private T data;
/** /**
* <p>Constructor for ApiResponse.</p>
*
* @param statusCode The status code of HTTP response * @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response * @param headers The headers of HTTP response
*/ */
@ -35,6 +35,8 @@ public class ApiResponse<T> {
} }
/** /**
* <p>Constructor for ApiResponse.</p>
*
* @param statusCode The status code of HTTP response * @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response * @param headers The headers of HTTP response
* @param data The object deserialized from response bod * @param data The object deserialized from response bod
@ -45,14 +47,29 @@ public class ApiResponse<T> {
this.data = data; this.data = data;
} }
/**
* <p>Get the <code>status code</code>.</p>
*
* @return the status code
*/
public int getStatusCode() { public int getStatusCode() {
return statusCode; return statusCode;
} }
/**
* <p>Get the <code>headers</code>.</p>
*
* @return a {@link java.util.Map} of headers
*/
public Map<String, List<String>> getHeaders() { public Map<String, List<String>> getHeaders() {
return headers; return headers;
} }
/**
* <p>Get the <code>data</code>.</p>
*
* @return the data
*/
public T getData() { public T getData() {
return data; return data;
} }

View File

@ -1,57 +1,21 @@
cmake_minimum_required (VERSION 3.2) cmake_minimum_required (VERSION 3.1)
project(cpprest-petstore)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (UNIX)
message(STATUS "Building for Linux/Unix")
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Wno-unused-variable -pg -g3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-unused-variable -pg -g3")
find_package(cpprestsdk REQUIRED)
find_package(Boost REQUIRED)
else()
message(STATUS "Building for Windows")
find_package(cpprestsdk REQUIRED)
find_package(Boost REQUIRED)
find_package(pthreads REQUIRED)
endif()
add_subdirectory(client) add_subdirectory(client)
file(GLOB SRCS project(cpprest-petstore)
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
find_package(Threads REQUIRED)
file(GLOB SOURCE_FILES "*.cpp")
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME}
PRIVATE
CppRestPetstoreClient
Threads::Threads
) )
add_executable(${PROJECT_NAME} ${SRCS})
add_dependencies(${PROJECT_NAME} CppRestOpenAPIClient )
target_include_directories(
${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/client
${CMAKE_CURRENT_SOURCE_DIR}/client/model
${CMAKE_CURRENT_SOURCE_DIR}/client/api
${Boost_INCLUDE_DIRS}
)
target_link_directories(
${PROJECT_NAME} PRIVATE
${Boost_LIBRARY_DIRS}
)
if (UNIX)
target_link_libraries(${PROJECT_NAME} PRIVATE CppRestOpenAPIClient cpprest pthread ${Boost_LIBRARIES} crypto)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE CppRestOpenAPIClient cpprestsdk::cpprest ${pthreads_LIBRARIES} ${Boost_LIBRARIES} bcrypt)
endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
if (UNIX) if (UNIX)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
endif() endif()

View File

@ -6,6 +6,7 @@ ApiConfiguration.h
ApiException.cpp ApiException.cpp
ApiException.h ApiException.h
CMakeLists.txt CMakeLists.txt
Config.cmake.in
HttpContent.cpp HttpContent.cpp
HttpContent.h HttpContent.h
IHttpBody.h IHttpBody.h

View File

@ -8,69 +8,85 @@
# #
# NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech). # NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech).
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 3.1)
#PROJECT's NAME project(CppRestPetstoreClient)
project(CppRestOpenAPIClient)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# THE LOCATION OF OUTPUT BINARIES set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/lib) set(CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
# BUILD TYPE find_package(cpprestsdk REQUIRED)
message("A ${CMAKE_BUILD_TYPE} build configuration is detected") find_package(Boost REQUIRED)
if (UNIX) include(GNUInstallDirs)
message(STATUS "Building client library for Linux/Unix") include(CMakePackageConfigHelpers)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Wno-unused-variable") file(GLOB_RECURSE HEADER_FILES "*.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-unused-variable") file(GLOB_RECURSE SOURCE_FILES "*.cpp")
set(cpprestsdk_DIR /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/cmake/)
find_package(cpprestsdk REQUIRED) add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
find_package(Boost REQUIRED)
else()
message(STATUS "Building client library for Windows")
find_package(cpprestsdk REQUIRED) target_compile_options(${PROJECT_NAME}
find_package(Boost REQUIRED) PRIVATE
endif() $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wno-unused-variable>
# Manually set the cpprestsdk paths when not using package manager
#set(CPPREST_INCLUDE_DIR ${CPPREST_ROOT}/include)
#set(CPPREST_LIBRARY_DIR ${CPPREST_ROOT}/lib)
#include_directories(${CPPREST_INCLUDE_DIR})
#link_directories(${CPPREST_LIBRARY_DIR})
#SUPPORTING FILES
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData" "Object")
#SOURCE FILES
file(GLOB SOURCE_FILES "api/*" "model/*")
add_library(${PROJECT_NAME} ${SUPPORTING_FILES} ${SOURCE_FILES})
target_include_directories(
${PROJECT_NAME} PRIVATE
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/model
${CMAKE_CURRENT_SOURCE_DIR}/api
) )
target_link_directories( target_include_directories(${PROJECT_NAME}
${PROJECT_NAME} PRIVATE PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_directories(${PROJECT_NAME}
PRIVATE
${Boost_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS}
) )
if (UNIX) if (UNIX)
target_link_libraries(${PROJECT_NAME} PRIVATE cpprest ${Boost_LIBRARIES} crypto) message(STATUS "Building client library for Linux/Unix")
target_link_libraries(${PROJECT_NAME} PUBLIC cpprest ${Boost_LIBRARIES} crypto)
else() else()
target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest ${Boost_LIBRARIES} bcrypt) message(STATUS "Building client library for Windows")
target_link_libraries(${PROJECT_NAME} PUBLIC cpprestsdk::cpprest ${Boost_LIBRARIES} bcrypt)
endif() endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.h"
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(
EXPORT ${PROJECT_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

View File

@ -0,0 +1,5 @@
@PACKAGE_INIT@
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)
check_required_components("@PROJECT_NAME@")

View File

@ -19,14 +19,13 @@
#define ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_
#include "../ApiClient.h"
#include "ApiResponse.h" #include "ApiClient.h"
#include "model/ApiResponse.h"
#include "HttpContent.h" #include "HttpContent.h"
#include "Pet.h" #include "model/Pet.h"
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>
#include <boost/optional.hpp> #include <boost/optional.hpp>
namespace org { namespace org {

View File

@ -19,13 +19,12 @@
#define ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_
#include "../ApiClient.h"
#include "Order.h" #include "ApiClient.h"
#include "model/Order.h"
#include <map> #include <map>
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>
#include <boost/optional.hpp> #include <boost/optional.hpp>
namespace org { namespace org {

View File

@ -19,13 +19,12 @@
#define ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_
#include "../ApiClient.h"
#include "User.h" #include "ApiClient.h"
#include "model/User.h"
#include <vector> #include <vector>
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>
#include <boost/optional.hpp> #include <boost/optional.hpp>
namespace org { namespace org {

View File

@ -19,7 +19,7 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_
#include "../ModelBase.h" #include "ModelBase.h"
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>

View File

@ -19,7 +19,7 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_
#include "../ModelBase.h" #include "ModelBase.h"
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>

View File

@ -19,7 +19,7 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_
#include "../ModelBase.h" #include "ModelBase.h"
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>

View File

@ -19,12 +19,12 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_
#include "../ModelBase.h" #include "ModelBase.h"
#include "Tag.h" #include "model/Tag.h"
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>
#include "Category.h"
#include <vector> #include <vector>
#include "model/Category.h"
namespace org { namespace org {
namespace openapitools { namespace openapitools {

View File

@ -19,7 +19,7 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_
#include "../ModelBase.h" #include "ModelBase.h"
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>

View File

@ -19,7 +19,7 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_
#include "../ModelBase.h" #include "ModelBase.h"
#include <cpprest/details/basic_types.h> #include <cpprest/details/basic_types.h>

View File

@ -1,39 +1,14 @@
# Generated by: https://openapi-generator.tech # Generated by: https://openapi-generator.tech
# #
*.gem /docs/
*.rbc /lib/
/.config /bin/
/coverage/ /.shards/
/InstalledFiles *.dwarf
/pkg/
/spec/reports/ # Libraries don't need dependency lock
/spec/examples.txt # Dependencies will be locked in applications that use them
/test/tmp/ /shard.lock
/test/version_tmp/
/tmp/ /tmp/
## Specific to RubyMotion:
.dat*
.repl_history
build/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

View File

@ -1,2 +0,0 @@
--color
--require spec_helper

View File

@ -1,148 +0,0 @@
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
# Automatically generated by OpenAPI Generator (https://openapi-generator.tech)
AllCops:
TargetRubyVersion: 2.4
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true
# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true
# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true
Layout/ElseAlignment:
Enabled: true
Layout/EmptyLineAfterMagicComment:
Enabled: true
# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true
# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true
# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/FirstArgumentIndentation:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: false
# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: indented_internal_methods
# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeComma:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true
Style/DefWithParentheses:
Enabled: true
# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: false
EnforcedStyle: always
# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true
# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideParens:
Enabled: true
# Check quotes usage according to lint rule below.
#Style/StringLiterals:
# Enabled: true
# EnforcedStyle: single_quotes
# Detect hard tabs, no hard tabs.
Layout/IndentationStyle:
Enabled: true
# Blank lines should not have any spaces.
Layout/TrailingEmptyLines:
Enabled: true
# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: false
# Use quotes for string literals when they are enough.
Style/RedundantPercentQ:
Enabled: true
# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
AutoCorrect: true
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true
Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true
Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true

View File

@ -6,8 +6,7 @@ version = '1.0.0'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,14 +76,17 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = 'petstore-feign-no-nullable' maven(MavenPublication) {
artifactId = 'petstore-feign-no-nullable'
from components.java
}
} }
} }

0
samples/client/petstore/java/feign-no-nullable/gradlew vendored Normal file → Executable file
View File

View File

@ -6,8 +6,7 @@ version = '1.0.0'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,14 +76,17 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = 'petstore-feign' maven(MavenPublication) {
artifactId = 'petstore-feign'
from components.java
}
} }
} }

View File

@ -6,8 +6,7 @@ version = '1.0.0'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.android.tools.build:gradle:2.3.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,14 +76,18 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = 'petstore-feign-10x' maven(MavenPublication) {
artifactId = 'petstore-feign-10x'
from components.java
}
} }
} }
@ -107,19 +110,19 @@ ext {
} }
dependencies { dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version" compileOnly "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.findbugs:jsr305:3.0.2" compileOnly "com.google.code.findbugs:jsr305:3.0.2"
compile "io.github.openfeign:feign-core:$feign_version" compileOnly "io.github.openfeign:feign-core:$feign_version"
compile "io.github.openfeign:feign-jackson:$feign_version" compileOnly "io.github.openfeign:feign-jackson:$feign_version"
compile "io.github.openfeign:feign-slf4j:$feign_version" compileOnly "io.github.openfeign:feign-slf4j:$feign_version"
compile "io.github.openfeign.form:feign-form:$feign_form_version" compileOnly "io.github.openfeign.form:feign-form:$feign_form_version"
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" compileOnly "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" compileOnly "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version" compileOnly "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version" compileOnly "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_threetenbp_version" compileOnly "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_threetenbp_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" compileOnly "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
compile "com.brsanthu:migbase64:2.2" compileOnly "com.brsanthu:migbase64:2.2"
compile 'javax.annotation:javax.annotation-api:1.3.2' compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
testCompile "junit:junit:$junit_version" testCompileOnly "junit:junit:$junit_version"
} }

View File

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

269
samples/client/petstore/java/feign/feign10x/gradlew vendored Normal file → Executable file
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/bin/sh
# #
# Copyright 2015 the original author or authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -17,78 +17,113 @@
# #
############################################################################## ##############################################################################
## #
## Gradle start up script for UN*X # Gradle start up script for POSIX generated by Gradle.
## #
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
############################################################################## ##############################################################################
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD="java" JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
@ -105,79 +140,95 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD=$( ulimit -H -n ) ||
MAX_FD="$MAX_FD_LIMIT" warn "Could not query maximum file descriptor limit"
fi esac
ulimit -n $MAX_FD case $MAX_FD in #(
if [ $? -ne 0 ] ; then '' | soft) :;; #(
warn "Could not set maximum file descriptor limit: $MAX_FD" *)
fi ulimit -n "$MAX_FD" ||
else warn "Could not set maximum file descriptor limit to $MAX_FD"
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=`save "$@"` # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"

View File

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -61,28 +64,14 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

0
samples/client/petstore/java/feign/gradlew vendored Normal file → Executable file
View File

View File

@ -6,8 +6,7 @@ version = '1.0.0'
buildscript { buildscript {
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.+' classpath 'com.android.tools.build:gradle:1.5.+'
@ -16,7 +15,7 @@ buildscript {
} }
repositories { repositories {
jcenter() mavenCentral()
} }
@ -77,14 +76,17 @@ if(hasProperty('target') && target == 'android') {
} else { } else {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7
install { publishing {
repositories.mavenInstaller { publications {
pom.artifactId = 'petstore-google-api-client' maven(MavenPublication) {
artifactId = 'petstore-google-api-client'
from components.java
}
} }
} }

0
samples/client/petstore/java/google-api-client/gradlew vendored Normal file → Executable file
View File

View File

@ -103,7 +103,7 @@ ext {
jakarta_annotation_version = "1.3.5" jakarta_annotation_version = "1.3.5"
jersey_version = "2.35" jersey_version = "2.35"
junit_version = "4.13.2" junit_version = "4.13.2"
scribejava_apis_version = "6.9.0" scribejava_apis_version = "8.3.1"
} }
dependencies { dependencies {

View File

@ -21,7 +21,7 @@ lazy val root = (project in file(".")).
"com.fasterxml.jackson.core" % "jackson-databind" % "2.13.0" % "compile", "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.0" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.13.0" % "compile", "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.13.0" % "compile",
"org.openapitools" % "jackson-databind-nullable" % "0.2.1" % "compile", "org.openapitools" % "jackson-databind-nullable" % "0.2.1" % "compile",
"com.github.scribejava" % "scribejava-apis" % "6.9.0" % "compile", "com.github.scribejava" % "scribejava-apis" % "8.3.1" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"junit" % "junit" % "4.13.2" % "test", "junit" % "junit" % "4.13.2" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test" "com.novocode" % "junit-interface" % "0.10" % "test"

View File

@ -36,7 +36,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version> <version>3.0.0</version>
<executions> <executions>
<execution> <execution>
<id>enforce-maven</id> <id>enforce-maven</id>
@ -56,7 +56,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version> <version>3.0.0-M5</version>
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
@ -84,16 +84,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- attach test jar --> <!-- attach test jar -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.6</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>jar</goal>
<goal>test-jar</goal> <goal>test-jar</goal>
</goals> </goals>
</execution> </execution>
@ -101,11 +99,10 @@
<configuration> <configuration>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>add_sources</id> <id>add_sources</id>
@ -152,7 +149,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version> <version>3.3.1</version>
<executions> <executions>
<execution> <execution>
<id>attach-javadocs</id> <id>attach-javadocs</id>
@ -176,7 +173,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
@ -308,6 +305,6 @@
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version> <jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version> <jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>4.13.2</junit-version> <junit-version>4.13.2</junit-version>
<scribejava-apis-version>6.9.0</scribejava-apis-version> <scribejava-apis-version>8.3.1</scribejava-apis-version>
</properties> </properties>
</project> </project>

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