forked from loafle/openapi-generator-original
Add more security samples (#3344)
* add line break test to petstore-security-test.yaml * add objc/swift security testing * add go,scala,qt5cpp for security test * add security test for typescript * fix go security issue, fix consumes,produces line break
This commit is contained in:
parent
d4951bbf3c
commit
394840e352
31
bin/security/go-petstore.sh
Executable file
31
bin/security/go-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l go -o samples/client/petstore-security-test/go"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
31
bin/security/objc-petstore.sh
Executable file
31
bin/security/objc-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/objc -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l objc -o samples/client/petstore-security-test/objc"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
31
bin/security/qt5cpp-petstore.sh
Executable file
31
bin/security/qt5cpp-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/qt5cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l qt5cpp -o samples/client/petstore-security-test/qt5cpp"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
15
bin/security/run-all-petstore-security-test
Executable file
15
bin/security/run-all-petstore-security-test
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
for SCRIPT in ./bin/security/*.sh
|
||||||
|
do
|
||||||
|
if [ -f $SCRIPT -a -x $SCRIPT ]
|
||||||
|
then
|
||||||
|
$SCRIPT
|
||||||
|
rc=$?
|
||||||
|
if [[ $rc != 0 ]]
|
||||||
|
then
|
||||||
|
echo "ERROR!! FAILED TO RUN $SCRIPT"
|
||||||
|
exit $rc;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
31
bin/security/scala-petstore.sh
Executable file
31
bin/security/scala-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/scala -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l scala -o samples/client/petstore-security-test/scala"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
31
bin/security/swift-petstore.sh
Executable file
31
bin/security/swift-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l swift -o samples/client/petstore-security-test/swift"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
31
bin/security/typescript-angular.sh
Executable file
31
bin/security/typescript-angular.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/typescript-angular -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l typescript-angular -o samples/client/petstore-security-test/typescript-angular"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
31
bin/security/typescript-angular2.sh
Executable file
31
bin/security/typescript-angular2.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/typescript-angular2 -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l typescript-angular2 -o samples/client/petstore-security-test/typescript-angular2"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
31
bin/security/typescript-fetch.sh
Executable file
31
bin/security/typescript-fetch.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/typescript-fetch -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l typescript-fetch -o samples/client/petstore-security-test/typescript-fetch"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
31
bin/security/typescript-node.sh
Executable file
31
bin/security/typescript-node.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/typescript-node -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l typescript-node -o samples/client/petstore-security-test/typescript-node"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -1774,7 +1774,7 @@ public class DefaultCodegen {
|
|||||||
for (String key : consumes) {
|
for (String key : consumes) {
|
||||||
Map<String, String> mediaType = new HashMap<String, String>();
|
Map<String, String> mediaType = new HashMap<String, String>();
|
||||||
// escape quotation to avoid code injection
|
// escape quotation to avoid code injection
|
||||||
mediaType.put("mediaType", escapeQuotationMark(key));
|
mediaType.put("mediaType", escapeText(escapeQuotationMark(key)));
|
||||||
count += 1;
|
count += 1;
|
||||||
if (count < consumes.size()) {
|
if (count < consumes.size()) {
|
||||||
mediaType.put("hasMore", "true");
|
mediaType.put("hasMore", "true");
|
||||||
@ -1808,7 +1808,7 @@ public class DefaultCodegen {
|
|||||||
for (String key : produces) {
|
for (String key : produces) {
|
||||||
Map<String, String> mediaType = new HashMap<String, String>();
|
Map<String, String> mediaType = new HashMap<String, String>();
|
||||||
// escape quotation to avoid code injection
|
// escape quotation to avoid code injection
|
||||||
mediaType.put("mediaType", escapeQuotationMark(key));
|
mediaType.put("mediaType", escapeText(escapeQuotationMark(key)));
|
||||||
count += 1;
|
count += 1;
|
||||||
if (count < produces.size()) {
|
if (count < produces.size()) {
|
||||||
mediaType.put("hasMore", "true");
|
mediaType.put("hasMore", "true");
|
||||||
|
@ -182,7 +182,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
@Override
|
@Override
|
||||||
public String toVarName(String name) {
|
public String toVarName(String name) {
|
||||||
// replace - with _ e.g. created-at => created_at
|
// replace - with _ e.g. created-at => created_at
|
||||||
name = name.replaceAll("-", "_");
|
name = sanitizeName(name.replaceAll("-", "_"));
|
||||||
|
|
||||||
// if it's all uppper case, do nothing
|
// if it's all uppper case, do nothing
|
||||||
if (name.matches("^[A-Z_]*$"))
|
if (name.matches("^[A-Z_]*$"))
|
||||||
@ -346,13 +346,15 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toOperationId(String operationId) {
|
public String toOperationId(String operationId) {
|
||||||
|
String sanitizedOperationId = new String(sanitizeName(operationId));
|
||||||
|
|
||||||
// method name cannot use reserved keyword, e.g. return
|
// method name cannot use reserved keyword, e.g. return
|
||||||
if (isReservedWord(operationId)) {
|
if (isReservedWord(sanitizedOperationId)) {
|
||||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize("call_" + operationId));
|
||||||
operationId = "call_" + operationId;
|
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return camelize(operationId);
|
return camelize(sanitizedOperationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,7 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
* @see io.swagger.codegen.CodegenType
|
* @see io.swagger.codegen.CodegenType
|
||||||
*/
|
*/
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
return CodegenType.CLIENT;
|
return CodegenType.SERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}} {
|
|||||||
{{#allParams}} * @param {{paramName}} {{description}}
|
{{#allParams}} * @param {{paramName}} {{description}}
|
||||||
{{/allParams}} * @return {{#returnType}}{{^isListContainer}}*{{/isListContainer}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
{{/allParams}} * @return {{#returnType}}{{^isListContainer}}*{{/isListContainer}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||||
*/
|
*/
|
||||||
func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{^isListContainer}}*{{/isListContainer}}{{{returnType}}}, {{/returnType}}*APIResponse, error) {
|
func (a {{{classname}}}) {{{nickname}}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{^isListContainer}}*{{/isListContainer}}{{{returnType}}}, {{/returnType}}*APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "{{httpMethod}}"
|
var httpMethod = "{{httpMethod}}"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
|
@ -25,7 +25,7 @@ type Configuration struct {
|
|||||||
|
|
||||||
func NewConfiguration() *Configuration {
|
func NewConfiguration() *Configuration {
|
||||||
return &Configuration{
|
return &Configuration{
|
||||||
BasePath: "{{basePath}}",
|
BasePath: "{{{basePath}}}",
|
||||||
UserName: "",
|
UserName: "",
|
||||||
debug: false,
|
debug: false,
|
||||||
DefaultHeader: make(map[string]string),
|
DefaultHeader: make(map[string]string),
|
||||||
|
@ -1,68 +1,68 @@
|
|||||||
swagger: '2.0'
|
swagger: '2.0'
|
||||||
info:
|
info:
|
||||||
description: "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end"
|
description: "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end \r\n \n \r"
|
||||||
version: 1.0.0 */ ' " =end
|
version: 1.0.0 */ ' " =end \r\n \n \r
|
||||||
title: Swagger Petstore */ ' " =end
|
title: Swagger Petstore */ ' " =end \r\n \n \r
|
||||||
termsOfService: http://swagger.io/terms/ */ ' " =end
|
termsOfService: http://swagger.io/terms/ */ ' " =end \r\n \n \r
|
||||||
contact:
|
contact:
|
||||||
email: apiteam@swagger.io */ ' " =end
|
email: apiteam@swagger.io */ ' " =end \r\n \n \r
|
||||||
license:
|
license:
|
||||||
name: Apache 2.0 */ ' " =end
|
name: Apache 2.0 */ ' " =end \r\n \n \r
|
||||||
url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end
|
url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end \r\n \n \r
|
||||||
host: petstore.swagger.io */ ' " =end
|
host: petstore.swagger.io */ ' " =end \r\n \n \r
|
||||||
basePath: /v2 */ ' " =end
|
basePath: /v2 */ ' " =end \r\n \n \r
|
||||||
tags:
|
tags:
|
||||||
- name: fake
|
- name: fake
|
||||||
description: Everything about your Pets */ ' " =end
|
description: Everything about your Pets */ ' " =end \r\n \n \r
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Find out more */ ' " = end
|
description: Find out more */ ' " =end \r\n \n \r
|
||||||
url: 'http://swagger.io'
|
url: 'http://swagger.io'
|
||||||
schemes:
|
schemes:
|
||||||
- http */ end ' "
|
- http */ ' " =end \r\n \n \r
|
||||||
paths:
|
paths:
|
||||||
/fake:
|
/fake:
|
||||||
put:
|
put:
|
||||||
tags:
|
tags:
|
||||||
- fake
|
- fake
|
||||||
summary: To test code injection */ ' " =end
|
summary: To test code injection */ ' " =end \r\n \n \r
|
||||||
descriptions: To test code injection */ ' " =end
|
descriptions: To test code injection */ ' " =end \r\n \n \r
|
||||||
operationId: testCodeInject */ ' " =end
|
operationId: testCodeInject */ ' " =end \r\n \n \r
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
- "*/ ' \" =end"
|
- "*/ ' \" =end \r\n \n \r"
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
- "*/ ' \" =end"
|
- "*/ ' \" =end \r\n \n \r"
|
||||||
parameters:
|
parameters:
|
||||||
- name: test code inject */ ' " =end
|
- name: test code inject */ ' " =end \r\n \n \r
|
||||||
type: string
|
type: string
|
||||||
in: formData
|
in: formData
|
||||||
description: To test code injection */ ' " =end
|
description: To test code injection */ ' " =end \r\n \n \r
|
||||||
responses:
|
responses:
|
||||||
'400':
|
'400':
|
||||||
description: To test code injection */ ' " =end
|
description: To test code injection */ ' " =end \r\n \n \r
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
petstore_auth:
|
petstore_auth:
|
||||||
type: oauth2
|
type: oauth2
|
||||||
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
|
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
|
||||||
flow: implicit
|
flow: implicit
|
||||||
scopes:
|
scopes:
|
||||||
'write:pets': modify pets in your account */ ' " =end
|
'write:pets': modify pets in your account */ ' " =end \r\n \n \r
|
||||||
'read:pets': read your pets */ ' " =end
|
'read:pets': read your pets */ ' " =end \r\n \n \r
|
||||||
api_key:
|
api_key:
|
||||||
type: apiKey
|
type: apiKey
|
||||||
name: api_key */ ' " =end
|
name: api_key */ ' " =end \r\n \n \r
|
||||||
in: header
|
in: header
|
||||||
definitions:
|
definitions:
|
||||||
Return:
|
Return:
|
||||||
description: Model for testing reserved words */ ' " =end
|
description: Model for testing reserved words */ ' " =end \r\n \n \r
|
||||||
properties:
|
properties:
|
||||||
return:
|
return:
|
||||||
description: property description */ ' " =end
|
description: property description */ ' " =end \r\n \n \r
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
xml:
|
xml:
|
||||||
name: Return
|
name: Return
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Find out more about Swagger */ ' " =end
|
description: Find out more about Swagger */ ' " =end \r\n \n \r
|
||||||
url: 'http://swagger.io'
|
url: 'http://swagger.io'
|
||||||
|
24
samples/client/petstore-security-test/go/.gitignore
vendored
Normal file
24
samples/client/petstore-security-test/go/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Folders
|
||||||
|
_obj
|
||||||
|
_test
|
||||||
|
|
||||||
|
# Architecture specific extensions/prefixes
|
||||||
|
*.[568vq]
|
||||||
|
[568vq].out
|
||||||
|
|
||||||
|
*.cgo1.go
|
||||||
|
*.cgo2.c
|
||||||
|
_cgo_defun.c
|
||||||
|
_cgo_gotypes.go
|
||||||
|
_cgo_export.*
|
||||||
|
|
||||||
|
_testmain.go
|
||||||
|
|
||||||
|
*.exe
|
||||||
|
*.test
|
||||||
|
*.prof
|
@ -0,0 +1,23 @@
|
|||||||
|
# Swagger Codegen Ignore
|
||||||
|
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
8
samples/client/petstore-security-test/go/.travis.yml
Normal file
8
samples/client/petstore-security-test/go/.travis.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
language: go
|
||||||
|
|
||||||
|
install:
|
||||||
|
- go get -d -v .
|
||||||
|
|
||||||
|
script:
|
||||||
|
- go build -v ./
|
||||||
|
|
201
samples/client/petstore-security-test/go/LICENSE
Normal file
201
samples/client/petstore-security-test/go/LICENSE
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
55
samples/client/petstore-security-test/go/README.md
Normal file
55
samples/client/petstore-security-test/go/README.md
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# Go API client for swagger
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.
|
||||||
|
|
||||||
|
- API version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
- Package version: 1.0.0
|
||||||
|
- Build date: 2016-07-12T18:49:24.937+08:00
|
||||||
|
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Put the package under your project folder and add the following in import:
|
||||||
|
```
|
||||||
|
"./swagger"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*FakeApi* | [**TestCodeInjectEndRnNR**](docs/FakeApi.md#testcodeinjectendrnnr) | **Put** /fake | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Models
|
||||||
|
|
||||||
|
- [ModelReturn](docs/ModelReturn.md)
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Authorization
|
||||||
|
|
||||||
|
|
||||||
|
## api_key
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key */ ' " =end \r\n \n \r
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
## petstore_auth
|
||||||
|
|
||||||
|
- **Type**: OAuth
|
||||||
|
- **Flow**: implicit
|
||||||
|
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
- **Scopes**:
|
||||||
|
- **write:pets**: modify pets in your account */ ' " =end \r\n \n \r
|
||||||
|
- **read:pets**: read your pets */ ' " =end \r\n \n \r
|
||||||
|
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
151
samples/client/petstore-security-test/go/api_client.go
Normal file
151
samples/client/petstore-security-test/go/api_client.go
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"net/url"
|
||||||
|
"github.com/go-resty/resty"
|
||||||
|
)
|
||||||
|
|
||||||
|
type APIClient struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
|
||||||
|
|
||||||
|
if len(contentTypes) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if contains(contentTypes, "application/json") {
|
||||||
|
return "application/json"
|
||||||
|
}
|
||||||
|
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *APIClient) SelectHeaderAccept(accepts []string) string {
|
||||||
|
|
||||||
|
if len(accepts) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if contains(accepts, "application/json") {
|
||||||
|
return "application/json"
|
||||||
|
}
|
||||||
|
return strings.Join(accepts, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
func contains(source []string, containvalue string) bool {
|
||||||
|
for _, a := range source {
|
||||||
|
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *APIClient) CallAPI(path string, method string,
|
||||||
|
postBody interface{},
|
||||||
|
headerParams map[string]string,
|
||||||
|
queryParams url.Values,
|
||||||
|
formParams map[string]string,
|
||||||
|
fileName string,
|
||||||
|
fileBytes []byte) (*resty.Response, error) {
|
||||||
|
|
||||||
|
//set debug flag
|
||||||
|
configuration := NewConfiguration()
|
||||||
|
resty.SetDebug(configuration.GetDebug())
|
||||||
|
|
||||||
|
request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
|
||||||
|
switch strings.ToUpper(method) {
|
||||||
|
case "GET":
|
||||||
|
response, err := request.Get(path)
|
||||||
|
return response, err
|
||||||
|
case "POST":
|
||||||
|
response, err := request.Post(path)
|
||||||
|
return response, err
|
||||||
|
case "PUT":
|
||||||
|
response, err := request.Put(path)
|
||||||
|
return response, err
|
||||||
|
case "PATCH":
|
||||||
|
response, err := request.Patch(path)
|
||||||
|
return response, err
|
||||||
|
case "DELETE":
|
||||||
|
response, err := request.Delete(path)
|
||||||
|
return response, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("invalid method %v", method)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *APIClient) ParameterToString(obj interface{},collectionFormat string) string {
|
||||||
|
if reflect.TypeOf(obj).String() == "[]string" {
|
||||||
|
switch collectionFormat {
|
||||||
|
case "pipes":
|
||||||
|
return strings.Join(obj.([]string), "|")
|
||||||
|
case "ssv":
|
||||||
|
return strings.Join(obj.([]string), " ")
|
||||||
|
case "tsv":
|
||||||
|
return strings.Join(obj.([]string), "\t")
|
||||||
|
case "csv" :
|
||||||
|
return strings.Join(obj.([]string), ",")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func prepareRequest(postBody interface{},
|
||||||
|
headerParams map[string]string,
|
||||||
|
queryParams url.Values,
|
||||||
|
formParams map[string]string,
|
||||||
|
fileName string,
|
||||||
|
fileBytes []byte) *resty.Request {
|
||||||
|
|
||||||
|
request := resty.R()
|
||||||
|
request.SetBody(postBody)
|
||||||
|
|
||||||
|
// add header parameter, if any
|
||||||
|
if len(headerParams) > 0 {
|
||||||
|
request.SetHeaders(headerParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
// add query parameter, if any
|
||||||
|
if len(queryParams) > 0 {
|
||||||
|
request.SetMultiValueQueryParams(queryParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
// add form parameter, if any
|
||||||
|
if len(formParams) > 0 {
|
||||||
|
request.SetFormData(formParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(fileBytes) > 0 && fileName != "" {
|
||||||
|
_, fileNm := filepath.Split(fileName)
|
||||||
|
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||||
|
}
|
||||||
|
return request
|
||||||
|
}
|
44
samples/client/petstore-security-test/go/api_response.go
Normal file
44
samples/client/petstore-security-test/go/api_response.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type APIResponse struct {
|
||||||
|
*http.Response
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||||
|
|
||||||
|
response := &APIResponse{Response: r}
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||||
|
|
||||||
|
response := &APIResponse{Message: errorMessage}
|
||||||
|
return response
|
||||||
|
}
|
81
samples/client/petstore-security-test/go/configuration.go
Normal file
81
samples/client/petstore-security-test/go/configuration.go
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Configuration struct {
|
||||||
|
UserName string `json:"userName,omitempty"`
|
||||||
|
Password string `json:"password,omitempty"`
|
||||||
|
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
|
||||||
|
APIKey map[string]string `json:"APIKey,omitempty"`
|
||||||
|
debug bool `json:"debug,omitempty"`
|
||||||
|
DebugFile string `json:"debugFile,omitempty"`
|
||||||
|
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||||
|
Timeout int `json:"timeout,omitempty"`
|
||||||
|
BasePath string `json:"basePath,omitempty"`
|
||||||
|
Host string `json:"host,omitempty"`
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
AccessToken string `json:"accessToken,omitempty"`
|
||||||
|
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||||
|
UserAgent string `json:"userAgent,omitempty"`
|
||||||
|
APIClient APIClient `json:"APIClient,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConfiguration() *Configuration {
|
||||||
|
return &Configuration{
|
||||||
|
BasePath: "https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r",
|
||||||
|
UserName: "",
|
||||||
|
debug: false,
|
||||||
|
DefaultHeader: make(map[string]string),
|
||||||
|
APIKey: make(map[string]string),
|
||||||
|
APIKeyPrefix: make(map[string]string),
|
||||||
|
UserAgent: "Swagger-Codegen/1.0.0/go",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) GetBasicAuthEncodedString() string {
|
||||||
|
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||||
|
c.DefaultHeader[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
||||||
|
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
|
||||||
|
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.APIKey[APIKeyIdentifier]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) SetDebug(enable bool) {
|
||||||
|
c.debug = enable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) GetDebug() bool {
|
||||||
|
return c.debug
|
||||||
|
}
|
36
samples/client/petstore-security-test/go/docs/FakeApi.md
Normal file
36
samples/client/petstore-security-test/go/docs/FakeApi.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# \FakeApi
|
||||||
|
|
||||||
|
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**TestCodeInjectEndRnNR**](FakeApi.md#TestCodeInjectEndRnNR) | **Put** /fake | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
|
# **TestCodeInjectEndRnNR**
|
||||||
|
> TestCodeInjectEndRnNR($testCodeInjectEndRnNR)
|
||||||
|
|
||||||
|
To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**testCodeInjectEndRnNR** | **string**| To test code injection *_/ ' \" =end \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, *_/ ' =end
|
||||||
|
- **Accept**: application/json, *_/ ' =end
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
10
samples/client/petstore-security-test/go/docs/ModelReturn.md
Normal file
10
samples/client/petstore-security-test/go/docs/ModelReturn.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# ModelReturn
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**Return_** | **int32** | property description *_/ ' \" =end \\r\\n \\n \\r | [optional] [default to null]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
107
samples/client/petstore-security-test/go/fake_api.go
Normal file
107
samples/client/petstore-security-test/go/fake_api.go
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"fmt"
|
||||||
|
"errors"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FakeApi struct {
|
||||||
|
Configuration Configuration
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFakeApi() *FakeApi {
|
||||||
|
configuration := NewConfiguration()
|
||||||
|
return &FakeApi{
|
||||||
|
Configuration: *configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFakeApiWithBasePath(basePath string) *FakeApi {
|
||||||
|
configuration := NewConfiguration()
|
||||||
|
configuration.BasePath = basePath
|
||||||
|
|
||||||
|
return &FakeApi{
|
||||||
|
Configuration: *configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
func (a FakeApi) TestCodeInjectEndRnNR(testCodeInjectEndRnNR string) (*APIResponse, error) {
|
||||||
|
|
||||||
|
var httpMethod = "Put"
|
||||||
|
// create path and map variables
|
||||||
|
path := a.Configuration.BasePath + "/fake"
|
||||||
|
|
||||||
|
|
||||||
|
headerParams := make(map[string]string)
|
||||||
|
queryParams := url.Values{}
|
||||||
|
formParams := make(map[string]string)
|
||||||
|
var postBody interface{}
|
||||||
|
var fileName string
|
||||||
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
|
for key := range a.Configuration.DefaultHeader {
|
||||||
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// to determine the Content-Type header
|
||||||
|
localVarHttpContentTypes := []string{ "application/json", "*_/ ' =end ", }
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/json",
|
||||||
|
"*_/ ' =end ",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
|
||||||
|
formParams["testCodeInjectEndRnNR"] = testCodeInjectEndRnNR
|
||||||
|
|
||||||
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
52
samples/client/petstore-security-test/go/git_push.sh
Normal file
52
samples/client/petstore-security-test/go/git_push.sh
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=`git remote`
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
||||||
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
30
samples/client/petstore-security-test/go/model_return.go
Normal file
30
samples/client/petstore-security-test/go/model_return.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package swagger
|
||||||
|
|
||||||
|
// Model for testing reserved words *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
type ModelReturn struct {
|
||||||
|
|
||||||
|
// property description *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
Return_ int32 `json:"return,omitempty"`
|
||||||
|
}
|
75
samples/client/petstore-security-test/go/pom.xml
Normal file
75
samples/client/petstore-security-test/go/pom.xml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.wordnik</groupId>
|
||||||
|
<artifactId>Goswagger</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>Goswagger</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-testify</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>github.com/stretchr/testify/assert</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-sling</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>github.com/dghubble/sling</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
<argument>-v</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
53
samples/client/petstore-security-test/objc/.gitignore
vendored
Normal file
53
samples/client/petstore-security-test/objc/.gitignore
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Xcode
|
||||||
|
#
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
## Build generated
|
||||||
|
build/
|
||||||
|
DerivedData
|
||||||
|
|
||||||
|
## Various settings
|
||||||
|
*.pbxuser
|
||||||
|
!default.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
!default.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
!default.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
!default.perspectivev3
|
||||||
|
xcuserdata
|
||||||
|
|
||||||
|
## Other
|
||||||
|
*.xccheckout
|
||||||
|
*.moved-aside
|
||||||
|
*.xcuserstate
|
||||||
|
*.xcscmblueprint
|
||||||
|
|
||||||
|
## Obj-C/Swift specific
|
||||||
|
*.hmap
|
||||||
|
*.ipa
|
||||||
|
|
||||||
|
# CocoaPods
|
||||||
|
#
|
||||||
|
# We recommend against adding the Pods directory to your .gitignore. However
|
||||||
|
# you should judge for yourself, the pros and cons are mentioned at:
|
||||||
|
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||||
|
#
|
||||||
|
# Pods/
|
||||||
|
|
||||||
|
# Carthage
|
||||||
|
#
|
||||||
|
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||||
|
# Carthage/Checkouts
|
||||||
|
|
||||||
|
Carthage/Build
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
#
|
||||||
|
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||||
|
# screenshots whenever they are needed.
|
||||||
|
# For more information about the recommended setup visit:
|
||||||
|
# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md
|
||||||
|
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/screenshots
|
@ -0,0 +1,23 @@
|
|||||||
|
# Swagger Codegen Ignore
|
||||||
|
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
201
samples/client/petstore-security-test/objc/LICENSE
Normal file
201
samples/client/petstore-security-test/objc/LICENSE
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
113
samples/client/petstore-security-test/objc/README.md
Normal file
113
samples/client/petstore-security-test/objc/README.md
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# SwaggerClient
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
|
||||||
|
This ObjC package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||||
|
|
||||||
|
- API version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
- Package version:
|
||||||
|
- Build date: 2016-07-12T17:06:42.405+08:00
|
||||||
|
- Build package: class io.swagger.codegen.languages.ObjcClientCodegen
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
The SDK requires [**ARC (Automatic Reference Counting)**](http://stackoverflow.com/questions/7778356/how-to-enable-disable-automatic-reference-counting) to be enabled in the Xcode project.
|
||||||
|
|
||||||
|
## Installation & Usage
|
||||||
|
### Install from Github using [CocoaPods](https://cocoapods.org/)
|
||||||
|
|
||||||
|
Add the following to the Podfile:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
pod 'SwaggerClient', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
|
||||||
|
```
|
||||||
|
|
||||||
|
To specify a particular branch, append `, :branch => 'branch-name-here'`
|
||||||
|
|
||||||
|
To specify a particular commit, append `, :commit => '11aa22'`
|
||||||
|
|
||||||
|
### Install from local path using [CocoaPods](https://cocoapods.org/)
|
||||||
|
|
||||||
|
Put the SDK under your project folder (e.g. /path/to/objc_project/Vendor/SwaggerClient) and then add the following to the Podfile:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
pod 'SwaggerClient', :path => 'Vendor/SwaggerClient'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
Import the following:
|
||||||
|
|
||||||
|
```objc
|
||||||
|
#import <SwaggerClient/SWGApiClient.h>
|
||||||
|
#import <SwaggerClient/SWGConfiguration.h>
|
||||||
|
// load models
|
||||||
|
#import <SwaggerClient/SWGReturn.h>
|
||||||
|
// load API classes for accessing endpoints
|
||||||
|
#import <SwaggerClient/SWGFakeApi.h>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issue.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||||
|
|
||||||
|
```objc
|
||||||
|
|
||||||
|
|
||||||
|
NSString* *testCodeInjectEndRnNR = @"testCodeInjectEndRnNR_example"; // To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional)
|
||||||
|
|
||||||
|
SWGFakeApi *apiInstance = [[SWGFakeApi alloc] init];
|
||||||
|
|
||||||
|
// To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
[apiInstance testCodeInjectEndRnNRWithTestCodeInjectEndRnNR:testCodeInjectEndRnNR
|
||||||
|
completionHandler: ^(NSError* error) {
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"Error: %@", error);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*SWGFakeApi* | [**testCodeInjectEndRnNR**](docs/SWGFakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Models
|
||||||
|
|
||||||
|
- [SWGReturn](docs/SWGReturn.md)
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Authorization
|
||||||
|
|
||||||
|
|
||||||
|
## api_key
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key */ ' " =end \r\n \n \r
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
## petstore_auth
|
||||||
|
|
||||||
|
- **Type**: OAuth
|
||||||
|
- **Flow**: implicit
|
||||||
|
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
- **Scopes**:
|
||||||
|
- **write:pets**: modify pets in your account */ ' " =end \r\n \n \r
|
||||||
|
- **read:pets**: read your pets */ ' " =end \r\n \n \r
|
||||||
|
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
#
|
||||||
|
# Be sure to run `pod lib lint SwaggerClient.podspec' to ensure this is a
|
||||||
|
# valid spec and remove all comments before submitting the spec.
|
||||||
|
#
|
||||||
|
# Any lines starting with a # are optional, but encouraged
|
||||||
|
#
|
||||||
|
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
|
||||||
|
#
|
||||||
|
|
||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = "SwaggerClient"
|
||||||
|
s.version = "1.0.0"
|
||||||
|
|
||||||
|
s.summary = "Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r"
|
||||||
|
s.description = <<-DESC
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
DESC
|
||||||
|
|
||||||
|
s.platform = :ios, '7.0'
|
||||||
|
s.requires_arc = true
|
||||||
|
|
||||||
|
s.framework = 'SystemConfiguration'
|
||||||
|
|
||||||
|
s.homepage = "https://github.com/swagger-api/swagger-codegen"
|
||||||
|
s.license = "Apache License, Version 2.0"
|
||||||
|
s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" }
|
||||||
|
s.author = { "Swagger" => "apiteam@swagger.io" }
|
||||||
|
|
||||||
|
s.source_files = 'SwaggerClient/**/*.{m,h}'
|
||||||
|
s.public_header_files = 'SwaggerClient/**/*.h'
|
||||||
|
|
||||||
|
|
||||||
|
s.dependency 'AFNetworking', '~> 3'
|
||||||
|
s.dependency 'JSONModel', '~> 1.2'
|
||||||
|
s.dependency 'ISO8601', '~> 0.5'
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "SWGApi.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@interface SWGFakeApi: NSObject <SWGApi>
|
||||||
|
|
||||||
|
extern NSString* kSWGFakeApiErrorDomain;
|
||||||
|
extern NSInteger kSWGFakeApiMissingParamErrorCode;
|
||||||
|
|
||||||
|
+(instancetype) sharedAPI;
|
||||||
|
|
||||||
|
/// To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional)
|
||||||
|
///
|
||||||
|
/// code:400 message:"To test code injection *_/ ' \" =end \\r\\n \\n \\r"
|
||||||
|
///
|
||||||
|
/// @return
|
||||||
|
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
|
||||||
|
completionHandler: (void (^)(NSError* error)) handler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,138 @@
|
|||||||
|
#import "SWGFakeApi.h"
|
||||||
|
#import "SWGQueryParamCollection.h"
|
||||||
|
|
||||||
|
|
||||||
|
@interface SWGFakeApi ()
|
||||||
|
|
||||||
|
@property (nonatomic, strong) NSMutableDictionary *defaultHeaders;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SWGFakeApi
|
||||||
|
|
||||||
|
NSString* kSWGFakeApiErrorDomain = @"SWGFakeApiErrorDomain";
|
||||||
|
NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
|
||||||
|
|
||||||
|
@synthesize apiClient = _apiClient;
|
||||||
|
|
||||||
|
#pragma mark - Initialize methods
|
||||||
|
|
||||||
|
- (instancetype) init {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
SWGConfiguration *config = [SWGConfiguration sharedConfig];
|
||||||
|
if (config.apiClient == nil) {
|
||||||
|
config.apiClient = [[SWGApiClient alloc] init];
|
||||||
|
}
|
||||||
|
_apiClient = config.apiClient;
|
||||||
|
_defaultHeaders = [NSMutableDictionary dictionary];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_apiClient = apiClient;
|
||||||
|
_defaultHeaders = [NSMutableDictionary dictionary];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
+ (instancetype)sharedAPI {
|
||||||
|
static SWGFakeApi *sharedAPI;
|
||||||
|
static dispatch_once_t once;
|
||||||
|
dispatch_once(&once, ^{
|
||||||
|
sharedAPI = [[self alloc] init];
|
||||||
|
});
|
||||||
|
return sharedAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(NSString*) defaultHeaderForKey:(NSString*)key {
|
||||||
|
return self.defaultHeaders[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||||
|
[self setDefaultHeaderValue:value forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key {
|
||||||
|
[self.defaultHeaders setValue:value forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(NSUInteger) requestQueueSize {
|
||||||
|
return [SWGApiClient requestQueueSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Api Methods
|
||||||
|
|
||||||
|
///
|
||||||
|
/// To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
///
|
||||||
|
/// @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional)
|
||||||
|
///
|
||||||
|
/// @returns void
|
||||||
|
///
|
||||||
|
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
|
||||||
|
completionHandler: (void (^)(NSError* error)) handler {
|
||||||
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/fake"];
|
||||||
|
|
||||||
|
// remove format in URL if needed
|
||||||
|
[resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)];
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders];
|
||||||
|
[headerParams addEntriesFromDictionary:self.defaultHeaders];
|
||||||
|
// HTTP header `Accept`
|
||||||
|
NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"*/ ' =end
|
||||||
|
|
||||||
|
"]];
|
||||||
|
if(acceptHeader.length > 0) {
|
||||||
|
headerParams[@"Accept"] = acceptHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @"";
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[@"application/json", @"*/ ' =end
|
||||||
|
|
||||||
|
"]];
|
||||||
|
|
||||||
|
// Authentication setting
|
||||||
|
NSArray *authSettings = @[];
|
||||||
|
|
||||||
|
id bodyParam = nil;
|
||||||
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||||
|
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
|
||||||
|
if (testCodeInjectEndRnNR) {
|
||||||
|
formParams[@"test code inject */ ' " =end \r\n \n \r"] = testCodeInjectEndRnNR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [self.apiClient requestWithPath: resourcePath
|
||||||
|
method: @"PUT"
|
||||||
|
pathParams: pathParams
|
||||||
|
queryParams: queryParams
|
||||||
|
formParams: formParams
|
||||||
|
files: localVarFiles
|
||||||
|
body: bodyParam
|
||||||
|
headerParams: headerParams
|
||||||
|
authSettings: authSettings
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
responseType: nil
|
||||||
|
completionBlock: ^(id data, NSError *error) {
|
||||||
|
if(handler) {
|
||||||
|
handler(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,31 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <ISO8601/ISO8601.h>
|
||||||
|
#import <JSONModel/JSONValueTransformer.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface JSONValueTransformer (ISO8601)
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,10 @@
|
|||||||
|
#import "JSONValueTransformer+ISO8601.h"
|
||||||
|
|
||||||
|
@implementation JSONValueTransformer (ISO8601)
|
||||||
|
|
||||||
|
- (NSDate *) NSDateFromNSString:(NSString *)string
|
||||||
|
{
|
||||||
|
return [NSDate dateWithISO8601String:string];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,42 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "SWGObject.h"
|
||||||
|
#import "SWGApiClient.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@protocol SWGApi <NSObject>
|
||||||
|
|
||||||
|
@property(nonatomic, assign) SWGApiClient *apiClient;
|
||||||
|
|
||||||
|
-(id) initWithApiClient:(SWGApiClient *)apiClient;
|
||||||
|
|
||||||
|
-(void) addHeader:(NSString*)value forKey:(NSString*)key DEPRECATED_MSG_ATTRIBUTE("setDefaultHeaderValue:forKey:");
|
||||||
|
|
||||||
|
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key;
|
||||||
|
-(NSString*) defaultHeaderForKey:(NSString*)key;
|
||||||
|
|
||||||
|
-(NSUInteger) requestQueueSize;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,206 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <ISO8601/ISO8601.h>
|
||||||
|
#import <AFNetworking/AFNetworking.h>
|
||||||
|
#import "SWGJSONResponseSerializer.h"
|
||||||
|
#import "SWGJSONRequestSerializer.h"
|
||||||
|
#import "SWGQueryParamCollection.h"
|
||||||
|
#import "SWGConfiguration.h"
|
||||||
|
#import "SWGResponseDeserializer.h"
|
||||||
|
#import "SWGSanitizer.h"
|
||||||
|
#import "SWGLogger.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "SWGReturn.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@class SWGConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A key for `NSError` user info dictionaries.
|
||||||
|
*
|
||||||
|
* The corresponding value is the parsed response body for an HTTP error.
|
||||||
|
*/
|
||||||
|
extern NSString *const SWGResponseObjectErrorKey;
|
||||||
|
|
||||||
|
@interface SWGApiClient : AFHTTPSessionManager
|
||||||
|
|
||||||
|
@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
|
||||||
|
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
||||||
|
@property(nonatomic, readonly) NSOperationQueue* queue;
|
||||||
|
|
||||||
|
/// In order to ensure the HTTPResponseHeaders are correct, it is recommended to initialize one SWGApiClient instance per thread.
|
||||||
|
@property(nonatomic, readonly) NSDictionary* HTTPResponseHeaders;
|
||||||
|
|
||||||
|
@property(nonatomic, strong) id<SWGResponseDeserializer> responseDeserializer;
|
||||||
|
|
||||||
|
@property(nonatomic, strong) id<SWGSanitizer> sanitizer;
|
||||||
|
/**
|
||||||
|
* Clears Cache
|
||||||
|
*/
|
||||||
|
+(void)clearCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on cache
|
||||||
|
*
|
||||||
|
* @param enabled If the cached is enable, must be `YES` or `NO`
|
||||||
|
*/
|
||||||
|
+(void)setCacheEnabled:(BOOL) enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the request queue size
|
||||||
|
*
|
||||||
|
* @return The size of `queuedRequests` static variable.
|
||||||
|
*/
|
||||||
|
+(NSUInteger)requestQueueSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the client unreachable
|
||||||
|
*
|
||||||
|
* @param state off line state, must be `YES` or `NO`
|
||||||
|
*/
|
||||||
|
+(void) setOfflineState:(BOOL) state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if the client is unreachable
|
||||||
|
*
|
||||||
|
* @return The client offline state
|
||||||
|
*/
|
||||||
|
+(BOOL) getOfflineState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the client reachability, this may be overridden by the reachability manager if reachability changes
|
||||||
|
*
|
||||||
|
* @param The client reachability.
|
||||||
|
*/
|
||||||
|
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the client reachability
|
||||||
|
*
|
||||||
|
* @return The client reachability.
|
||||||
|
*/
|
||||||
|
+(AFNetworkReachabilityStatus) getReachabilityStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the next request id
|
||||||
|
*
|
||||||
|
* @return The next executed request id.
|
||||||
|
*/
|
||||||
|
+(NSNumber*) nextRequestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates request id and add it to the queue
|
||||||
|
*
|
||||||
|
* @return The next executed request id.
|
||||||
|
*/
|
||||||
|
+(NSNumber*) queueRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes request id from the queue
|
||||||
|
*
|
||||||
|
* @param requestId The request which will be removed.
|
||||||
|
*/
|
||||||
|
+(void) cancelRequest:(NSNumber*)requestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customizes the behavior when the reachability changed
|
||||||
|
*
|
||||||
|
* @param changeBlock The block will be executed when the reachability changed.
|
||||||
|
*/
|
||||||
|
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the api client reachability strategy
|
||||||
|
*/
|
||||||
|
- (void)configureCacheReachibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets header for request
|
||||||
|
*
|
||||||
|
* @param value The header value
|
||||||
|
* @param forKey The header key
|
||||||
|
*/
|
||||||
|
-(void)setHeaderValue:(NSString*) value
|
||||||
|
forKey:(NSString*) forKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates header parameters and query parameters for authentication
|
||||||
|
*
|
||||||
|
* @param headers The header parameter will be udpated, passed by pointer to pointer.
|
||||||
|
* @param querys The query parameters will be updated, passed by pointer to pointer.
|
||||||
|
* @param authSettings The authentication names NSArray.
|
||||||
|
*/
|
||||||
|
- (void) updateHeaderParams:(NSDictionary **)headers
|
||||||
|
queryParams:(NSDictionary **)querys
|
||||||
|
WithAuthSettings:(NSArray *)authSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs request
|
||||||
|
*
|
||||||
|
* @param path Request url.
|
||||||
|
* @param method Request method.
|
||||||
|
* @param pathParams Request path parameters.
|
||||||
|
* @param queryParams Request query parameters.
|
||||||
|
* @param body Request body.
|
||||||
|
* @param headerParams Request header parameters.
|
||||||
|
* @param authSettings Request authentication names.
|
||||||
|
* @param requestContentType Request content-type.
|
||||||
|
* @param responseContentType Response content-type.
|
||||||
|
* @param completionBlock The block will be executed when the request completed.
|
||||||
|
*
|
||||||
|
* @return The request id.
|
||||||
|
*/
|
||||||
|
-(NSNumber*) requestWithPath:(NSString*) path
|
||||||
|
method:(NSString*) method
|
||||||
|
pathParams:(NSDictionary *) pathParams
|
||||||
|
queryParams:(NSDictionary*) queryParams
|
||||||
|
formParams:(NSDictionary *) formParams
|
||||||
|
files:(NSDictionary *) files
|
||||||
|
body:(id) body
|
||||||
|
headerParams:(NSDictionary*) headerParams
|
||||||
|
authSettings:(NSArray *) authSettings
|
||||||
|
requestContentType:(NSString*) requestContentType
|
||||||
|
responseContentType:(NSString*) responseContentType
|
||||||
|
responseType:(NSString *) responseType
|
||||||
|
completionBlock:(void (^)(id, NSError *))completionBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom security policy
|
||||||
|
*
|
||||||
|
* @return AFSecurityPolicy
|
||||||
|
*/
|
||||||
|
- (AFSecurityPolicy *) customSecurityPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SWGConfiguration return sharedConfig
|
||||||
|
*
|
||||||
|
* @return SWGConfiguration
|
||||||
|
*/
|
||||||
|
- (SWGConfiguration*) configuration;
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,504 @@
|
|||||||
|
#import "SWGApiClient.h"
|
||||||
|
|
||||||
|
NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject";
|
||||||
|
|
||||||
|
static NSUInteger requestId = 0;
|
||||||
|
static bool offlineState = false;
|
||||||
|
static NSMutableSet * queuedRequests = nil;
|
||||||
|
static bool cacheEnabled = false;
|
||||||
|
static AFNetworkReachabilityStatus reachabilityStatus = AFNetworkReachabilityStatusNotReachable;
|
||||||
|
static void (^reachabilityChangeBlock)(int);
|
||||||
|
|
||||||
|
|
||||||
|
static NSDictionary * SWG__headerFieldsForResponse(NSURLResponse *response) {
|
||||||
|
if(![response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return ((NSHTTPURLResponse*)response).allHeaderFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
|
||||||
|
NSDictionary * headers = SWG__headerFieldsForResponse(response);
|
||||||
|
if(!headers[@"Content-Disposition"]) {
|
||||||
|
return [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]];
|
||||||
|
}
|
||||||
|
NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?";
|
||||||
|
NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern
|
||||||
|
options:NSRegularExpressionCaseInsensitive
|
||||||
|
error:nil];
|
||||||
|
NSString *contentDispositionHeader = headers[@"Content-Disposition"];
|
||||||
|
NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader
|
||||||
|
options:0
|
||||||
|
range:NSMakeRange(0, [contentDispositionHeader length])];
|
||||||
|
return [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@interface SWGApiClient ()
|
||||||
|
|
||||||
|
@property (nonatomic, strong) NSDictionary* HTTPResponseHeaders;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SWGApiClient
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
NSString *baseUrl = [[SWGConfiguration sharedConfig] host];
|
||||||
|
return [self initWithBaseURL:[NSURL URLWithString:baseUrl]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithBaseURL:(NSURL *)url {
|
||||||
|
self = [super initWithBaseURL:url];
|
||||||
|
if (self) {
|
||||||
|
self.timeoutInterval = 60;
|
||||||
|
self.requestSerializer = [AFJSONRequestSerializer serializer];
|
||||||
|
self.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||||
|
self.securityPolicy = [self customSecurityPolicy];
|
||||||
|
self.responseDeserializer = [[SWGResponseDeserializer alloc] init];
|
||||||
|
self.sanitizer = [[SWGSanitizer alloc] init];
|
||||||
|
// configure reachability
|
||||||
|
[self configureCacheReachibility];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)initialize {
|
||||||
|
if (self == [SWGApiClient class]) {
|
||||||
|
queuedRequests = [[NSMutableSet alloc] init];
|
||||||
|
// initialize URL cache
|
||||||
|
[self configureCacheWithMemoryAndDiskCapacity:4*1024*1024 diskSize:32*1024*1024];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Setter Methods
|
||||||
|
|
||||||
|
+ (void) setOfflineState:(BOOL) state {
|
||||||
|
offlineState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) setCacheEnabled:(BOOL)enabled {
|
||||||
|
cacheEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus)status {
|
||||||
|
reachabilityStatus = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey {
|
||||||
|
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setRequestSerializer:(AFHTTPRequestSerializer<AFURLRequestSerialization> *)requestSerializer {
|
||||||
|
[super setRequestSerializer:requestSerializer];
|
||||||
|
requestSerializer.timeoutInterval = self.timeoutInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Cache Methods
|
||||||
|
|
||||||
|
+(void)clearCache {
|
||||||
|
[[NSURLCache sharedURLCache] removeAllCachedResponses];
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void)configureCacheWithMemoryAndDiskCapacity: (unsigned long) memorySize
|
||||||
|
diskSize: (unsigned long) diskSize {
|
||||||
|
NSAssert(memorySize > 0, @"invalid in-memory cache size");
|
||||||
|
NSAssert(diskSize >= 0, @"invalid disk cache size");
|
||||||
|
|
||||||
|
NSURLCache *cache =
|
||||||
|
[[NSURLCache alloc]
|
||||||
|
initWithMemoryCapacity:memorySize
|
||||||
|
diskCapacity:diskSize
|
||||||
|
diskPath:@"swagger_url_cache"];
|
||||||
|
|
||||||
|
[NSURLCache setSharedURLCache:cache];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Request Methods
|
||||||
|
|
||||||
|
+(NSUInteger)requestQueueSize {
|
||||||
|
return [queuedRequests count];
|
||||||
|
}
|
||||||
|
|
||||||
|
+(NSNumber*) nextRequestId {
|
||||||
|
@synchronized(self) {
|
||||||
|
return @(++requestId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+(NSNumber*) queueRequest {
|
||||||
|
NSNumber* requestId = [[self class] nextRequestId];
|
||||||
|
SWGDebugLog(@"added %@ to request queue", requestId);
|
||||||
|
[queuedRequests addObject:requestId];
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void) cancelRequest:(NSNumber*)requestId {
|
||||||
|
[queuedRequests removeObject:requestId];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(Boolean) executeRequestWithId:(NSNumber*) requestId {
|
||||||
|
NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) {
|
||||||
|
return [obj intValue] == [requestId intValue];
|
||||||
|
}];
|
||||||
|
|
||||||
|
if (matchingItems.count == 1) {
|
||||||
|
SWGDebugLog(@"removed request id %@", requestId);
|
||||||
|
[queuedRequests removeObject:requestId];
|
||||||
|
return YES;
|
||||||
|
} else {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Reachability Methods
|
||||||
|
|
||||||
|
+(AFNetworkReachabilityStatus) getReachabilityStatus {
|
||||||
|
return reachabilityStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(BOOL) getOfflineState {
|
||||||
|
return offlineState;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock {
|
||||||
|
reachabilityChangeBlock = changeBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) configureCacheReachibility {
|
||||||
|
[self.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
||||||
|
reachabilityStatus = status;
|
||||||
|
SWGDebugLog(@"reachability changed to %@",AFStringFromNetworkReachabilityStatus(status));
|
||||||
|
[SWGApiClient setOfflineState:status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable];
|
||||||
|
|
||||||
|
// call the reachability block, if configured
|
||||||
|
if (reachabilityChangeBlock != nil) {
|
||||||
|
reachabilityChangeBlock(status);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
[self.reachabilityManager startMonitoring];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Operation Methods
|
||||||
|
|
||||||
|
- (void) operationWithCompletionBlock: (NSURLRequest *)request
|
||||||
|
requestId: (NSNumber *) requestId
|
||||||
|
completionBlock: (void (^)(id, NSError *))completionBlock {
|
||||||
|
__weak __typeof(self)weakSelf = self;
|
||||||
|
NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||||
|
__strong __typeof(weakSelf)strongSelf = weakSelf;
|
||||||
|
if (![strongSelf executeRequestWithId:requestId]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SWGDebugLogResponse(response, responseObject,request,error);
|
||||||
|
strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response);
|
||||||
|
if(!error) {
|
||||||
|
completionBlock(responseObject, nil);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
|
||||||
|
if (responseObject) {
|
||||||
|
// Add in the (parsed) response body.
|
||||||
|
userInfo[SWGResponseObjectErrorKey] = responseObject;
|
||||||
|
}
|
||||||
|
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
|
||||||
|
completionBlock(nil, augmentedError);
|
||||||
|
}];
|
||||||
|
[op resume];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) downloadOperationWithCompletionBlock: (NSURLRequest *)request
|
||||||
|
requestId: (NSNumber *) requestId
|
||||||
|
completionBlock: (void (^)(id, NSError *))completionBlock {
|
||||||
|
__weak __typeof(self)weakSelf = self;
|
||||||
|
NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||||
|
__strong __typeof(weakSelf)strongSelf = weakSelf;
|
||||||
|
if (![strongSelf executeRequestWithId:requestId]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response);
|
||||||
|
SWGDebugLogResponse(response, responseObject,request,error);
|
||||||
|
if(error) {
|
||||||
|
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
|
||||||
|
if (responseObject) {
|
||||||
|
userInfo[SWGResponseObjectErrorKey] = responseObject;
|
||||||
|
}
|
||||||
|
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
|
||||||
|
completionBlock(nil, augmentedError);
|
||||||
|
}
|
||||||
|
NSString *directory = [self configuration].tempFolderPath ?: NSTemporaryDirectory();
|
||||||
|
NSString * filename = SWG__fileNameForResponse(response);
|
||||||
|
|
||||||
|
NSString *filepath = [directory stringByAppendingPathComponent:filename];
|
||||||
|
NSURL *file = [NSURL fileURLWithPath:filepath];
|
||||||
|
|
||||||
|
[responseObject writeToURL:file atomically:YES];
|
||||||
|
|
||||||
|
completionBlock(file, nil);
|
||||||
|
}];
|
||||||
|
[op resume];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Perform Request Methods
|
||||||
|
|
||||||
|
-(NSNumber*) requestWithPath: (NSString*) path
|
||||||
|
method: (NSString*) method
|
||||||
|
pathParams: (NSDictionary *) pathParams
|
||||||
|
queryParams: (NSDictionary*) queryParams
|
||||||
|
formParams: (NSDictionary *) formParams
|
||||||
|
files: (NSDictionary *) files
|
||||||
|
body: (id) body
|
||||||
|
headerParams: (NSDictionary*) headerParams
|
||||||
|
authSettings: (NSArray *) authSettings
|
||||||
|
requestContentType: (NSString*) requestContentType
|
||||||
|
responseContentType: (NSString*) responseContentType
|
||||||
|
responseType: (NSString *) responseType
|
||||||
|
completionBlock: (void (^)(id, NSError *))completionBlock {
|
||||||
|
// setting request serializer
|
||||||
|
if ([requestContentType isEqualToString:@"application/json"]) {
|
||||||
|
self.requestSerializer = [SWGJSONRequestSerializer serializer];
|
||||||
|
}
|
||||||
|
else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) {
|
||||||
|
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||||
|
}
|
||||||
|
else if ([requestContentType isEqualToString:@"multipart/form-data"]) {
|
||||||
|
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||||
|
NSAssert(NO, @"Unsupported request type %@", requestContentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// setting response serializer
|
||||||
|
if ([responseContentType isEqualToString:@"application/json"]) {
|
||||||
|
self.responseSerializer = [SWGJSONResponseSerializer serializer];
|
||||||
|
} else {
|
||||||
|
self.responseSerializer = [AFHTTPResponseSerializer serializer];
|
||||||
|
}
|
||||||
|
|
||||||
|
// sanitize parameters
|
||||||
|
pathParams = [self.sanitizer sanitizeForSerialization:pathParams];
|
||||||
|
queryParams = [self.sanitizer sanitizeForSerialization:queryParams];
|
||||||
|
headerParams = [self.sanitizer sanitizeForSerialization:headerParams];
|
||||||
|
formParams = [self.sanitizer sanitizeForSerialization:formParams];
|
||||||
|
if(![body isKindOfClass:[NSData class]]) {
|
||||||
|
body = [self.sanitizer sanitizeForSerialization:body];
|
||||||
|
}
|
||||||
|
|
||||||
|
// auth setting
|
||||||
|
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
|
||||||
|
|
||||||
|
NSMutableString *resourcePath = [NSMutableString stringWithString:path];
|
||||||
|
[pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
NSString * safeString = ([obj isKindOfClass:[NSString class]]) ? obj : [NSString stringWithFormat:@"%@", obj];
|
||||||
|
safeString = SWGPercentEscapedStringFromString(safeString);
|
||||||
|
[resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"{%@}", key]] withString:safeString];
|
||||||
|
}];
|
||||||
|
|
||||||
|
NSMutableURLRequest * request = nil;
|
||||||
|
|
||||||
|
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams];
|
||||||
|
if ([pathWithQueryParams hasPrefix:@"/"]) {
|
||||||
|
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||||
|
if (files.count > 0) {
|
||||||
|
__weak __typeof(self)weakSelf = self;
|
||||||
|
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
|
||||||
|
URLString:urlString
|
||||||
|
parameters:nil
|
||||||
|
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||||
|
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
NSString *objString = [weakSelf.sanitizer parameterToString:obj];
|
||||||
|
NSData *data = [objString dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
[formData appendPartWithFormData:data name:key];
|
||||||
|
}];
|
||||||
|
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
NSURL *filePath = (NSURL *)obj;
|
||||||
|
[formData appendPartWithFileURL:filePath name:key error:nil];
|
||||||
|
}];
|
||||||
|
} error:nil];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (formParams) {
|
||||||
|
request = [self.requestSerializer requestWithMethod:method
|
||||||
|
URLString:urlString
|
||||||
|
parameters:formParams
|
||||||
|
error:nil];
|
||||||
|
}
|
||||||
|
if (body) {
|
||||||
|
request = [self.requestSerializer requestWithMethod:method
|
||||||
|
URLString:urlString
|
||||||
|
parameters:body
|
||||||
|
error:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// request cache
|
||||||
|
BOOL hasHeaderParams = [headerParams count] > 0;
|
||||||
|
if (offlineState) {
|
||||||
|
SWGDebugLog(@"%@ cache forced", resourcePath);
|
||||||
|
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
||||||
|
}
|
||||||
|
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
|
||||||
|
SWGDebugLog(@"%@ cache enabled", resourcePath);
|
||||||
|
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SWGDebugLog(@"%@ cache disabled", resourcePath);
|
||||||
|
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasHeaderParams){
|
||||||
|
for(NSString * key in [headerParams keyEnumerator]){
|
||||||
|
[request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"];
|
||||||
|
|
||||||
|
[self postProcessRequest:request];
|
||||||
|
|
||||||
|
NSNumber* requestId = [SWGApiClient queueRequest];
|
||||||
|
if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) {
|
||||||
|
[self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) {
|
||||||
|
completionBlock(data, error);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) {
|
||||||
|
NSError * serializationError;
|
||||||
|
id response = [self.responseDeserializer deserialize:data class:responseType error:&serializationError];
|
||||||
|
if(!response && !error){
|
||||||
|
error = serializationError;
|
||||||
|
}
|
||||||
|
completionBlock(response, error);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Added for easier override to modify request
|
||||||
|
-(void)postProcessRequest:(NSMutableURLRequest *)request {
|
||||||
|
// Always disable cookies!
|
||||||
|
[request setHTTPShouldHandleCookies:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (NSString*) pathWithQueryParamsToString:(NSString*) path
|
||||||
|
queryParams:(NSDictionary*) queryParams {
|
||||||
|
if(queryParams.count == 0) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
NSString * separator = nil;
|
||||||
|
NSUInteger counter = 0;
|
||||||
|
|
||||||
|
NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path];
|
||||||
|
|
||||||
|
NSDictionary *separatorStyles = @{@"csv" : @",",
|
||||||
|
@"tsv" : @"\t",
|
||||||
|
@"pipes": @"|"
|
||||||
|
};
|
||||||
|
for(NSString * key in [queryParams keyEnumerator]){
|
||||||
|
if (counter == 0) {
|
||||||
|
separator = @"?";
|
||||||
|
} else {
|
||||||
|
separator = @"&";
|
||||||
|
}
|
||||||
|
id queryParam = [queryParams valueForKey:key];
|
||||||
|
if(!queryParam) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
NSString *safeKey = SWGPercentEscapedStringFromString(key);
|
||||||
|
if ([queryParam isKindOfClass:[NSString class]]){
|
||||||
|
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, SWGPercentEscapedStringFromString(queryParam)]];
|
||||||
|
|
||||||
|
} else if ([queryParam isKindOfClass:[SWGQueryParamCollection class]]){
|
||||||
|
SWGQueryParamCollection * coll = (SWGQueryParamCollection*) queryParam;
|
||||||
|
NSArray* values = [coll values];
|
||||||
|
NSString* format = [coll format];
|
||||||
|
|
||||||
|
if([format isEqualToString:@"multi"]) {
|
||||||
|
for(id obj in values) {
|
||||||
|
if (counter > 0) {
|
||||||
|
separator = @"&";
|
||||||
|
}
|
||||||
|
NSString * safeValue = SWGPercentEscapedStringFromString([NSString stringWithFormat:@"%@",obj]);
|
||||||
|
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]];
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
NSString * separatorStyle = separatorStyles[format];
|
||||||
|
NSString * safeValue = SWGPercentEscapedStringFromString([values componentsJoinedByString:separatorStyle]);
|
||||||
|
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]];
|
||||||
|
} else {
|
||||||
|
NSString * safeValue = SWGPercentEscapedStringFromString([NSString stringWithFormat:@"%@",queryParam]);
|
||||||
|
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]];
|
||||||
|
}
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
return requestUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update header and query params based on authentication settings
|
||||||
|
*/
|
||||||
|
- (void) updateHeaderParams:(NSDictionary *__autoreleasing *)headers
|
||||||
|
queryParams:(NSDictionary *__autoreleasing *)querys
|
||||||
|
WithAuthSettings:(NSArray *)authSettings {
|
||||||
|
|
||||||
|
if ([authSettings count] == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers];
|
||||||
|
NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys];
|
||||||
|
|
||||||
|
NSDictionary* configurationAuthSettings = [[self configuration] authSettings];
|
||||||
|
for (NSString *auth in authSettings) {
|
||||||
|
NSDictionary *authSetting = configurationAuthSettings[auth];
|
||||||
|
if(!authSetting) { // auth setting is set only if the key is non-empty
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
NSString *type = authSetting[@"in"];
|
||||||
|
NSString *key = authSetting[@"key"];
|
||||||
|
NSString *value = authSetting[@"value"];
|
||||||
|
if ([type isEqualToString:@"header"] && [key length] > 0 ) {
|
||||||
|
headersWithAuth[key] = value;
|
||||||
|
} else if ([type isEqualToString:@"query"] && [key length] != 0) {
|
||||||
|
querysWithAuth[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*headers = [NSDictionary dictionaryWithDictionary:headersWithAuth];
|
||||||
|
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (AFSecurityPolicy *) customSecurityPolicy {
|
||||||
|
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
||||||
|
|
||||||
|
SWGConfiguration *config = [self configuration];
|
||||||
|
|
||||||
|
if (config.sslCaCert) {
|
||||||
|
NSData *certData = [NSData dataWithContentsOfFile:config.sslCaCert];
|
||||||
|
[securityPolicy setPinnedCertificates:@[certData]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.verifySSL) {
|
||||||
|
[securityPolicy setAllowInvalidCertificates:NO];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[securityPolicy setAllowInvalidCertificates:YES];
|
||||||
|
[securityPolicy setValidatesDomainName:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
return securityPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (SWGConfiguration*) configuration {
|
||||||
|
return [SWGConfiguration sharedConfig];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,182 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "SWGApiClient.h"
|
||||||
|
#import "SWGLogger.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@class SWGApiClient;
|
||||||
|
|
||||||
|
@interface SWGConfiguration : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default api logger
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) SWGLogger * logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default api client
|
||||||
|
*/
|
||||||
|
@property (nonatomic) SWGApiClient *apiClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default base url
|
||||||
|
*/
|
||||||
|
@property (nonatomic) NSString *host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api key values for Api Key type Authentication
|
||||||
|
*
|
||||||
|
* To add or remove api key, use `setApiKey:forApiKeyIdentifier:`.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSDictionary *apiKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api key prefix values to be prepend to the respective api key
|
||||||
|
*
|
||||||
|
* To add or remove prefix, use `setApiKeyPrefix:forApiKeyPrefixIdentifier:`.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Username for HTTP Basic Authentication
|
||||||
|
*/
|
||||||
|
@property (nonatomic) NSString *username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Password for HTTP Basic Authentication
|
||||||
|
*/
|
||||||
|
@property (nonatomic) NSString *password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access token for OAuth
|
||||||
|
*/
|
||||||
|
@property (nonatomic) NSString *accessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temp folder for file download
|
||||||
|
*/
|
||||||
|
@property (nonatomic) NSString *tempFolderPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug switch, default false
|
||||||
|
*/
|
||||||
|
@property (nonatomic) BOOL debug;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets configuration singleton instance
|
||||||
|
*/
|
||||||
|
+ (instancetype) sharedConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SSL/TLS verification
|
||||||
|
* Set this to NO to skip verifying SSL certificate when calling API from https server
|
||||||
|
*/
|
||||||
|
@property (nonatomic) BOOL verifySSL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SSL/TLS verification
|
||||||
|
* Set this to customize the certificate file to verify the peer
|
||||||
|
*/
|
||||||
|
@property (nonatomic) NSString *sslCaCert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets API key
|
||||||
|
*
|
||||||
|
* To remove a apiKey for an identifier, just set the apiKey to nil.
|
||||||
|
*
|
||||||
|
* @param apiKey API key or token.
|
||||||
|
* @param identifier API key identifier (authentication schema).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString*)identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes api key
|
||||||
|
*
|
||||||
|
* @param identifier API key identifier.
|
||||||
|
*/
|
||||||
|
- (void) removeApiKey:(NSString *)identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the prefix for API key
|
||||||
|
*
|
||||||
|
* @param apiKeyPrefix API key prefix.
|
||||||
|
* @param identifier API key identifier.
|
||||||
|
*/
|
||||||
|
- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes api key prefix
|
||||||
|
*
|
||||||
|
* @param identifier API key identifier.
|
||||||
|
*/
|
||||||
|
- (void) removeApiKeyPrefix:(NSString *)identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets API key (with prefix if set)
|
||||||
|
*/
|
||||||
|
- (NSString *) getApiKeyWithPrefix:(NSString *) key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Basic Auth token
|
||||||
|
*/
|
||||||
|
- (NSString *) getBasicAuthToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets OAuth access token
|
||||||
|
*/
|
||||||
|
- (NSString *) getAccessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Authentication Settings
|
||||||
|
*/
|
||||||
|
- (NSDictionary *) authSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default headers for all services
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSDictionary *defaultHeaders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes header from defaultHeaders
|
||||||
|
*
|
||||||
|
* @param Header name.
|
||||||
|
*/
|
||||||
|
-(void) removeDefaultHeaderForKey:(NSString*)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the header for key
|
||||||
|
*
|
||||||
|
* @param value Value for header name
|
||||||
|
* @param key Header name
|
||||||
|
*/
|
||||||
|
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Header key name.
|
||||||
|
*/
|
||||||
|
-(NSString*) defaultHeaderForKey:(NSString*)key;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,160 @@
|
|||||||
|
#import "SWGConfiguration.h"
|
||||||
|
|
||||||
|
@interface SWGConfiguration ()
|
||||||
|
|
||||||
|
@property (nonatomic, strong) NSMutableDictionary *mutableDefaultHeaders;
|
||||||
|
@property (nonatomic, strong) NSMutableDictionary *mutableApiKey;
|
||||||
|
@property (nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SWGConfiguration
|
||||||
|
|
||||||
|
#pragma mark - Singleton Methods
|
||||||
|
|
||||||
|
+ (instancetype) sharedConfig {
|
||||||
|
static SWGConfiguration *shardConfig = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
shardConfig = [[self alloc] init];
|
||||||
|
});
|
||||||
|
return shardConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Initialize Methods
|
||||||
|
|
||||||
|
- (instancetype) init {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
self.apiClient = nil;
|
||||||
|
self.host = @"https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r";
|
||||||
|
self.username = @"";
|
||||||
|
self.password = @"";
|
||||||
|
self.accessToken= @"";
|
||||||
|
self.verifySSL = YES;
|
||||||
|
self.mutableApiKey = [NSMutableDictionary dictionary];
|
||||||
|
self.mutableApiKeyPrefix = [NSMutableDictionary dictionary];
|
||||||
|
self.mutableDefaultHeaders = [NSMutableDictionary dictionary];
|
||||||
|
self.mutableDefaultHeaders[@"User-Agent"] = [NSString stringWithFormat:@"Swagger-Codegen/1.0.0 *_/ ' \" =end \\r\\n \\n \\r/objc (%@; iOS %@; Scale/%0.2f)",[[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
|
||||||
|
self.logger = [SWGLogger sharedLogger];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Instance Methods
|
||||||
|
|
||||||
|
- (NSString *) getApiKeyWithPrefix:(NSString *)key {
|
||||||
|
NSString *prefix = self.apiKeyPrefix[key];
|
||||||
|
NSString *apiKey = self.apiKey[key];
|
||||||
|
if (prefix && apiKey != (id)[NSNull null] && apiKey.length > 0) { // both api key prefix and api key are set
|
||||||
|
return [NSString stringWithFormat:@"%@ %@", prefix, apiKey];
|
||||||
|
}
|
||||||
|
else if (apiKey != (id)[NSNull null] && apiKey.length > 0) { // only api key, no api key prefix
|
||||||
|
return [NSString stringWithFormat:@"%@", self.apiKey[key]];
|
||||||
|
}
|
||||||
|
else { // return empty string if nothing is set
|
||||||
|
return @"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) getBasicAuthToken {
|
||||||
|
// return empty string if username and password are empty
|
||||||
|
if (self.username.length == 0 && self.password.length == 0){
|
||||||
|
return @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password];
|
||||||
|
NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]];
|
||||||
|
|
||||||
|
return basicAuthCredentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) getAccessToken {
|
||||||
|
if (self.accessToken.length == 0) { // token not set, return empty string
|
||||||
|
return @"";
|
||||||
|
} else {
|
||||||
|
return [NSString stringWithFormat:@"Bearer %@", self.accessToken];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Setter Methods
|
||||||
|
|
||||||
|
- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString *)identifier {
|
||||||
|
[self.mutableApiKey setValue:apiKey forKey:identifier];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) removeApiKey:(NSString *)identifier {
|
||||||
|
[self.mutableApiKey removeObjectForKey:identifier];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier {
|
||||||
|
[self.mutableApiKeyPrefix setValue:prefix forKey:identifier];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) removeApiKeyPrefix:(NSString *)identifier {
|
||||||
|
[self.mutableApiKeyPrefix removeObjectForKey:identifier];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Getter Methods
|
||||||
|
|
||||||
|
- (NSDictionary *) apiKey {
|
||||||
|
return [NSDictionary dictionaryWithDictionary:self.mutableApiKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *) apiKeyPrefix {
|
||||||
|
return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (NSDictionary *) authSettings {
|
||||||
|
return @{
|
||||||
|
@"api_key":
|
||||||
|
@{
|
||||||
|
@"type": @"api_key",
|
||||||
|
@"in": @"header",
|
||||||
|
@"key": @"api_key */ ' " =end \r\n \n \r",
|
||||||
|
@"value": [self getApiKeyWithPrefix:@"api_key */ ' " =end \r\n \n \r"]
|
||||||
|
},
|
||||||
|
@"petstore_auth":
|
||||||
|
@{
|
||||||
|
@"type": @"oauth",
|
||||||
|
@"in": @"header",
|
||||||
|
@"key": @"Authorization",
|
||||||
|
@"value": [self getAccessToken]
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)debug {
|
||||||
|
return self.logger.isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)setDebug:(BOOL)debug {
|
||||||
|
self.logger.enabled = debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- (void)setDefaultHeaderValue:(NSString *)value forKey:(NSString *)key {
|
||||||
|
if(!value) {
|
||||||
|
[self.mutableDefaultHeaders removeObjectForKey:key];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.mutableDefaultHeaders[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) removeDefaultHeaderForKey:(NSString*)key {
|
||||||
|
[self.mutableDefaultHeaders removeObjectForKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)defaultHeaderForKey:(NSString *)key {
|
||||||
|
return self.mutableDefaultHeaders[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)defaultHeaders {
|
||||||
|
return [self.mutableDefaultHeaders copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,29 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <AFNetworking/AFURLRequestSerialization.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface SWGJSONRequestSerializer : AFJSONRequestSerializer
|
||||||
|
@end
|
@ -0,0 +1,37 @@
|
|||||||
|
#import "SWGJSONRequestSerializer.h"
|
||||||
|
|
||||||
|
@implementation SWGJSONRequestSerializer
|
||||||
|
|
||||||
|
///
|
||||||
|
/// When customize a request serializer,
|
||||||
|
/// the serializer must conform the protocol `AFURLRequestSerialization`
|
||||||
|
/// and implements the protocol method `requestBySerializingRequest:withParameters:error:`
|
||||||
|
///
|
||||||
|
/// @param request The original request.
|
||||||
|
/// @param parameters The parameters to be encoded.
|
||||||
|
/// @param error The error that occurred while attempting to encode the request parameters.
|
||||||
|
///
|
||||||
|
/// @return A serialized request.
|
||||||
|
///
|
||||||
|
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
|
withParameters:(id)parameters
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (!parameters) {
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
// If the body data which will be serialized isn't NSArray or NSDictionary
|
||||||
|
// then put the data in the http request body directly.
|
||||||
|
if ([parameters isKindOfClass:[NSArray class]] || [parameters isKindOfClass:[NSDictionary class]]) {
|
||||||
|
return [super requestBySerializingRequest:request withParameters:parameters error:error];
|
||||||
|
}
|
||||||
|
NSMutableURLRequest *mutableRequest = [request mutableCopy];
|
||||||
|
if([parameters isKindOfClass:[NSData class]]) {
|
||||||
|
[mutableRequest setHTTPBody:parameters];
|
||||||
|
} else {
|
||||||
|
[mutableRequest setHTTPBody:[parameters dataUsingEncoding:self.stringEncoding]];
|
||||||
|
}
|
||||||
|
return mutableRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,30 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <AFNetworking/AFURLResponseSerialization.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface SWGJSONResponseSerializer : AFJSONResponseSerializer
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,39 @@
|
|||||||
|
#import "SWGJSONResponseSerializer.h"
|
||||||
|
|
||||||
|
@implementation SWGJSONResponseSerializer
|
||||||
|
|
||||||
|
///
|
||||||
|
/// When customize a response serializer,
|
||||||
|
/// the serializer must conform the protocol `AFURLResponseSerialization`
|
||||||
|
/// and implements the protocol method `responseObjectForResponse:error:`
|
||||||
|
///
|
||||||
|
/// @param response The response to be processed.
|
||||||
|
/// @param data The response data to be decoded.
|
||||||
|
/// @param error The error that occurred while attempting to decode the response data.
|
||||||
|
///
|
||||||
|
/// @return The object decoded from the specified response data.
|
||||||
|
///
|
||||||
|
- (id) responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error {
|
||||||
|
NSDictionary *responseJson = [super responseObjectForResponse:response data:data error:error];
|
||||||
|
|
||||||
|
// if response data is not a valid json, return string of data.
|
||||||
|
if ([self isParseError:*error]) {
|
||||||
|
*error = nil;
|
||||||
|
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||||
|
return responseString;
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)isParseError:(NSError *)error {
|
||||||
|
return [error.domain isEqualToString:NSCocoaErrorDomain] && error.code == 3840;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
return [self serializerWithReadingOptions:NSJSONReadingAllowFragments];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,72 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SWGDebugLogResponse
|
||||||
|
#define SWGDebugLogResponse(response, responseObject,request, error) [[SWGLogger sharedLogger] logResponse:response responseObject:responseObject request:request error:error];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log debug message macro
|
||||||
|
*/
|
||||||
|
#ifndef SWGDebugLog
|
||||||
|
#define SWGDebugLog(format, ...) [[SWGLogger sharedLogger] debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface SWGLogger : NSObject
|
||||||
|
|
||||||
|
+(instancetype)sharedLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enabled switch, default NO - default set by SWGConfiguration debug property
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign, getter=isEnabled) BOOL enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug file location, default log in console
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) NSString *loggingFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log file handler, this property is used by sdk internally.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong, readonly) NSFileHandle *loggingFileHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log debug message
|
||||||
|
*/
|
||||||
|
-(void)debugLog:(NSString *)method message:(NSString *)format, ...;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs request and response
|
||||||
|
*
|
||||||
|
* @param response NSURLResponse for the HTTP request.
|
||||||
|
* @param responseObject response object of the HTTP request.
|
||||||
|
* @param request The HTTP request.
|
||||||
|
* @param error The error of the HTTP request.
|
||||||
|
*/
|
||||||
|
- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,74 @@
|
|||||||
|
#import "SWGLogger.h"
|
||||||
|
|
||||||
|
@interface SWGLogger ()
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SWGLogger
|
||||||
|
|
||||||
|
+ (instancetype) sharedLogger {
|
||||||
|
static SWGLogger *shardLogger = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
shardLogger = [[self alloc] init];
|
||||||
|
});
|
||||||
|
return shardLogger;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Log Methods
|
||||||
|
|
||||||
|
- (void)debugLog:(NSString *)method
|
||||||
|
message:(NSString *)format, ... {
|
||||||
|
if (!self.isEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableString *message = [NSMutableString stringWithCapacity:1];
|
||||||
|
|
||||||
|
if (method) {
|
||||||
|
[message appendFormat:@"%@: ", method];
|
||||||
|
}
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
|
||||||
|
[message appendString:[[NSString alloc] initWithFormat:format arguments:args]];
|
||||||
|
|
||||||
|
// If set logging file handler, log into file,
|
||||||
|
// otherwise log into console.
|
||||||
|
if (self.loggingFileHandler) {
|
||||||
|
[self.loggingFileHandler seekToEndOfFile];
|
||||||
|
[self.loggingFileHandler writeData:[message dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
|
} else {
|
||||||
|
NSLog(@"%@", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error {
|
||||||
|
NSString *message = [NSString stringWithFormat:@"\n[DEBUG] HTTP request body \n~BEGIN~\n %@\n~END~\n"\
|
||||||
|
"[DEBUG] HTTP response body \n~BEGIN~\n %@\n~END~\n",
|
||||||
|
[[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding],
|
||||||
|
responseObject];
|
||||||
|
|
||||||
|
SWGDebugLog(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setLoggingFile:(NSString *)loggingFile {
|
||||||
|
if(_loggingFile == loggingFile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// close old file handler
|
||||||
|
if ([self.loggingFileHandler isKindOfClass:[NSFileHandle class]]) {
|
||||||
|
[self.loggingFileHandler closeFile];
|
||||||
|
}
|
||||||
|
_loggingFile = loggingFile;
|
||||||
|
_loggingFileHandler = [NSFileHandle fileHandleForWritingAtPath:_loggingFile];
|
||||||
|
if (_loggingFileHandler == nil) {
|
||||||
|
[[NSFileManager defaultManager] createFileAtPath:_loggingFile contents:nil attributes:nil];
|
||||||
|
_loggingFileHandler = [NSFileHandle fileHandleForWritingAtPath:_loggingFile];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,30 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <JSONModel/JSONModel.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface SWGObject : JSONModel
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,13 @@
|
|||||||
|
#import "SWGObject.h"
|
||||||
|
|
||||||
|
@implementation SWGObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the string presentation of the object.
|
||||||
|
* This method will be called when logging model object using `NSLog`.
|
||||||
|
*/
|
||||||
|
- (NSString *)description {
|
||||||
|
return [[self toDictionary] description];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,35 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface SWGQueryParamCollection : NSObject
|
||||||
|
|
||||||
|
@property(nonatomic, readonly) NSArray* values;
|
||||||
|
@property(nonatomic, readonly) NSString* format;
|
||||||
|
|
||||||
|
- (id) initWithValuesAndFormat: (NSArray*) values
|
||||||
|
format: (NSString*) format;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,16 @@
|
|||||||
|
#import "SWGQueryParamCollection.h"
|
||||||
|
|
||||||
|
@implementation SWGQueryParamCollection
|
||||||
|
|
||||||
|
@synthesize values = _values;
|
||||||
|
@synthesize format = _format;
|
||||||
|
|
||||||
|
- (id) initWithValuesAndFormat: (NSArray*) values
|
||||||
|
format: (NSString*) format {
|
||||||
|
_values = values;
|
||||||
|
_format = format;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,68 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A key for deserialization ErrorDomain
|
||||||
|
*/
|
||||||
|
extern NSString *const SWGDeserializationErrorDomainKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code for deserialization type mismatch error
|
||||||
|
*/
|
||||||
|
extern NSInteger const SWGTypeMismatchErrorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code for deserialization empty value error
|
||||||
|
*/
|
||||||
|
extern NSInteger const SWGEmptyValueOccurredErrorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error code for unknown response
|
||||||
|
*/
|
||||||
|
extern NSInteger const SWGUnknownResponseObjectErrorCode;
|
||||||
|
|
||||||
|
@protocol SWGResponseDeserializer <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserializes the given data to Objective-C object.
|
||||||
|
*
|
||||||
|
* @param data The data will be deserialized.
|
||||||
|
* @param class The type of objective-c object.
|
||||||
|
* @param error The error
|
||||||
|
*/
|
||||||
|
- (id) deserialize:(id) data class:(NSString *) className error:(NSError**)error;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface SWGResponseDeserializer : NSObject <SWGResponseDeserializer>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If an null value occurs in dictionary or array if set to YES whole response will be invalid else will be ignored
|
||||||
|
* @default NO
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL treatNullAsError;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,231 @@
|
|||||||
|
#import "SWGResponseDeserializer.h"
|
||||||
|
#import <JSONModel/JSONModel.h>
|
||||||
|
#import <ISO8601/ISO8601.h>
|
||||||
|
|
||||||
|
NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey";
|
||||||
|
|
||||||
|
NSInteger const SWGTypeMismatchErrorCode = 143553;
|
||||||
|
|
||||||
|
NSInteger const SWGEmptyValueOccurredErrorCode = 143509;
|
||||||
|
|
||||||
|
NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
|
||||||
|
|
||||||
|
|
||||||
|
@interface SWGResponseDeserializer ()
|
||||||
|
|
||||||
|
@property (nonatomic, strong) NSNumberFormatter* numberFormatter;
|
||||||
|
@property (nonatomic, strong) NSArray *primitiveTypes;
|
||||||
|
@property (nonatomic, strong) NSArray *basicReturnTypes;
|
||||||
|
|
||||||
|
@property (nonatomic, strong) NSRegularExpression* arrayOfModelsPatExpression;
|
||||||
|
@property (nonatomic, strong) NSRegularExpression* arrayOfPrimitivesPatExpression;
|
||||||
|
@property (nonatomic, strong) NSRegularExpression* dictPatExpression;
|
||||||
|
@property (nonatomic, strong) NSRegularExpression* dictModelsPatExpression;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SWGResponseDeserializer
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
|
||||||
|
formatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||||
|
_numberFormatter = formatter;
|
||||||
|
_primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"];
|
||||||
|
_basicReturnTypes = @[@"NSObject", @"id", @"NSData"];
|
||||||
|
_arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>"
|
||||||
|
options:NSRegularExpressionCaseInsensitive
|
||||||
|
error:nil];
|
||||||
|
_arrayOfPrimitivesPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray\\* /\\* (.+) \\*/"
|
||||||
|
options:NSRegularExpressionCaseInsensitive
|
||||||
|
error:nil];
|
||||||
|
_dictPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\* /\\* (.+?), (.+) \\*/"
|
||||||
|
options:NSRegularExpressionCaseInsensitive
|
||||||
|
error:nil];
|
||||||
|
_dictModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\<(.+?), (.+)*\\>"
|
||||||
|
options:NSRegularExpressionCaseInsensitive
|
||||||
|
error:nil];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Deserialize methods
|
||||||
|
|
||||||
|
- (id) deserialize:(id) data class:(NSString *) className error:(NSError **) error {
|
||||||
|
// return nil if data is nil or className is nil
|
||||||
|
if (!data || !className || [data isKindOfClass:[NSNull class]]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove "*" from className, if ends with "*"
|
||||||
|
if ([className hasSuffix:@"*"]) {
|
||||||
|
className = [className substringToIndex:[className length] - 1];
|
||||||
|
}
|
||||||
|
// pure object
|
||||||
|
if ([self.basicReturnTypes containsObject:className]) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// primitives
|
||||||
|
if ([self.primitiveTypes containsObject:className]) {
|
||||||
|
return [self deserializePrimitiveValue:data class:className error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSTextCheckingResult *match = nil;
|
||||||
|
NSRange range = NSMakeRange(0, [className length]);
|
||||||
|
// list of models
|
||||||
|
match = [self.arrayOfModelsPatExpression firstMatchInString:className options:0 range:range];
|
||||||
|
if (match) {
|
||||||
|
NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]];
|
||||||
|
return [self deserializeArrayValue:data innerType:innerType error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
// list of primitives
|
||||||
|
match = [self.arrayOfPrimitivesPatExpression firstMatchInString:className options:0 range:range];
|
||||||
|
if (match) {
|
||||||
|
NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]];
|
||||||
|
return [self deserializeArrayValue:data innerType:innerType error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
// map
|
||||||
|
match = [self.dictPatExpression firstMatchInString:className options:0 range:range];
|
||||||
|
if (match) {
|
||||||
|
NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]];
|
||||||
|
return [self deserializeDictionaryValue:data valueType:valueType error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
match = [self.dictModelsPatExpression firstMatchInString:className options:0 range:range];
|
||||||
|
if (match) {
|
||||||
|
NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]];
|
||||||
|
return [self deserializeDictionaryValue:data valueType:valueType error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
// model
|
||||||
|
Class ModelClass = NSClassFromString(className);
|
||||||
|
if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) {
|
||||||
|
return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
*error = [self unknownResponseErrorWithExpectedType:className data:data];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) deserializeDictionaryValue:(id) data valueType:(NSString *) valueType error:(NSError**)error {
|
||||||
|
if(![data isKindOfClass: [NSDictionary class]]) {
|
||||||
|
if(error) {
|
||||||
|
*error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDictionary class]) data:data];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
__block NSMutableDictionary *resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]];
|
||||||
|
for (id key in [data allKeys]) {
|
||||||
|
id obj = [data valueForKey:key];
|
||||||
|
id dicObj = [self deserialize:obj class:valueType error:error];
|
||||||
|
if(dicObj) {
|
||||||
|
[resultDict setValue:dicObj forKey:key];
|
||||||
|
} else if([obj isKindOfClass:[NSNull class]]) {
|
||||||
|
if(self.treatNullAsError) {
|
||||||
|
if (error) {
|
||||||
|
*error = [self emptyValueOccurredError];
|
||||||
|
}
|
||||||
|
resultDict = nil;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resultDict = nil;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) deserializeArrayValue:(id) data innerType:(NSString *) innerType error:(NSError**)error {
|
||||||
|
if(![data isKindOfClass: [NSArray class]]) {
|
||||||
|
if(error) {
|
||||||
|
*error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSArray class]) data:data];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
NSMutableArray* resultArray = [NSMutableArray arrayWithCapacity:[data count]];
|
||||||
|
for (id obj in data) {
|
||||||
|
id arrObj = [self deserialize:obj class:innerType error:error];
|
||||||
|
if(arrObj) {
|
||||||
|
[resultArray addObject:arrObj];
|
||||||
|
} else if([obj isKindOfClass:[NSNull class]]) {
|
||||||
|
if(self.treatNullAsError) {
|
||||||
|
if (error) {
|
||||||
|
*error = [self emptyValueOccurredError];
|
||||||
|
}
|
||||||
|
resultArray = nil;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resultArray = nil;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
- (id) deserializePrimitiveValue:(id) data class:(NSString *) className error:(NSError**)error {
|
||||||
|
if ([className isEqualToString:@"NSString"]) {
|
||||||
|
return [NSString stringWithString:data];
|
||||||
|
}
|
||||||
|
else if ([className isEqualToString:@"NSDate"]) {
|
||||||
|
return [self deserializeDateValue:data error:error];
|
||||||
|
}
|
||||||
|
else if ([className isEqualToString:@"NSNumber"]) {
|
||||||
|
// NSNumber from NSNumber
|
||||||
|
if ([data isKindOfClass:[NSNumber class]]) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
else if ([data isKindOfClass:[NSString class]]) {
|
||||||
|
// NSNumber (NSCFBoolean) from NSString
|
||||||
|
if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) {
|
||||||
|
return @([data boolValue]);
|
||||||
|
// NSNumber from NSString
|
||||||
|
} else {
|
||||||
|
NSNumber* formattedValue = [self.numberFormatter numberFromString:data];
|
||||||
|
if(!formattedValue && [data length] > 0 && error) {
|
||||||
|
*error = [self typeMismatchErrorWithExpectedType:className data:data];
|
||||||
|
}
|
||||||
|
return formattedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(error) {
|
||||||
|
*error = [self typeMismatchErrorWithExpectedType:className data:data];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) deserializeDateValue:(id) data error:(NSError**)error {
|
||||||
|
NSDate *date =[NSDate dateWithISO8601String:data];
|
||||||
|
if(!date && [data length] > 0 && error) {
|
||||||
|
*error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDate class]) data:data];
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
};
|
||||||
|
|
||||||
|
-(NSError *)typeMismatchErrorWithExpectedType:(NSString *)expected data:(id)data {
|
||||||
|
NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Received response [%@] is not an object of type %@",nil),data, expected];
|
||||||
|
NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message};
|
||||||
|
return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(NSError *)emptyValueOccurredError {
|
||||||
|
NSString * message = NSLocalizedString(@"Received response contains null value in dictionary or array response",nil);
|
||||||
|
NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message};
|
||||||
|
return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGEmptyValueOccurredErrorCode userInfo:userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(NSError *)unknownResponseErrorWithExpectedType:(NSString *)expected data:(id)data {
|
||||||
|
NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Unknown response expected type %@ [reponse: %@]",nil),expected,data];
|
||||||
|
NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message};
|
||||||
|
return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGUnknownResponseObjectErrorCode userInfo:userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,67 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern NSString * SWGPercentEscapedStringFromString(NSString *string);
|
||||||
|
|
||||||
|
@protocol SWGSanitizer <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitize object for request
|
||||||
|
*
|
||||||
|
* @param object The query/path/header/form/body param to be sanitized.
|
||||||
|
*/
|
||||||
|
- (id) sanitizeForSerialization:(id) object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert parameter to NSString
|
||||||
|
*/
|
||||||
|
- (NSString *) parameterToString: (id) param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detects Accept header from accepts NSArray
|
||||||
|
*
|
||||||
|
* @param accepts NSArray of header
|
||||||
|
*
|
||||||
|
* @return The Accept header
|
||||||
|
*/
|
||||||
|
-(NSString *) selectHeaderAccept:(NSArray *)accepts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detects Content-Type header from contentTypes NSArray
|
||||||
|
*
|
||||||
|
* @param contentTypes NSArray of header
|
||||||
|
*
|
||||||
|
* @return The Content-Type header
|
||||||
|
*/
|
||||||
|
-(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface SWGSanitizer : NSObject <SWGSanitizer>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,168 @@
|
|||||||
|
#import "SWGSanitizer.h"
|
||||||
|
#import "SWGObject.h"
|
||||||
|
#import "SWGQueryParamCollection.h"
|
||||||
|
#import <ISO8601/ISO8601.h>
|
||||||
|
|
||||||
|
NSString * SWGPercentEscapedStringFromString(NSString *string) {
|
||||||
|
static NSString * const kSWGCharactersGeneralDelimitersToEncode = @":#[]@";
|
||||||
|
static NSString * const kSWGCharactersSubDelimitersToEncode = @"!$&'()*+,;=";
|
||||||
|
|
||||||
|
NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
|
||||||
|
[allowedCharacterSet removeCharactersInString:[kSWGCharactersGeneralDelimitersToEncode stringByAppendingString:kSWGCharactersSubDelimitersToEncode]];
|
||||||
|
|
||||||
|
static NSUInteger const batchSize = 50;
|
||||||
|
|
||||||
|
NSUInteger index = 0;
|
||||||
|
NSMutableString *escaped = @"".mutableCopy;
|
||||||
|
|
||||||
|
while (index < string.length) {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wgnu"
|
||||||
|
NSUInteger length = MIN(string.length - index, batchSize);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
NSRange range = NSMakeRange(index, length);
|
||||||
|
|
||||||
|
// To avoid breaking up character sequences such as 👴🏻👮🏽
|
||||||
|
range = [string rangeOfComposedCharacterSequencesForRange:range];
|
||||||
|
|
||||||
|
NSString *substring = [string substringWithRange:range];
|
||||||
|
NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
|
||||||
|
[escaped appendString:encoded];
|
||||||
|
|
||||||
|
index += range.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return escaped;
|
||||||
|
}
|
||||||
|
|
||||||
|
@interface SWGSanitizer ()
|
||||||
|
|
||||||
|
@property (nonatomic, strong) NSRegularExpression* jsonHeaderTypeExpression;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SWGSanitizer
|
||||||
|
|
||||||
|
static NSString * kApplicationJSONType = @"application/json";
|
||||||
|
|
||||||
|
-(instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if ( !self ) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
_jsonHeaderTypeExpression = [NSRegularExpression regularExpressionWithPattern:@"(.*)application(.*)json(.*)" options:NSRegularExpressionCaseInsensitive error:nil];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (id) sanitizeForSerialization:(id) object {
|
||||||
|
if (object == nil) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSDate class]]) {
|
||||||
|
return [self dateParameterToString:object];
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSArray class]]) {
|
||||||
|
NSArray *objectArray = object;
|
||||||
|
NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]];
|
||||||
|
[object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
id sanitizedObj = [self sanitizeForSerialization:obj];
|
||||||
|
if (sanitizedObj) {
|
||||||
|
[sanitizedObjs addObject:sanitizedObj];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return sanitizedObjs;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSDictionary *objectDict = object;
|
||||||
|
NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]];
|
||||||
|
[object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
id sanitizedObj = [self sanitizeForSerialization:obj];
|
||||||
|
if (sanitizedObj) {
|
||||||
|
sanitizedObjs[key] = sanitizedObj;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return sanitizedObjs;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[SWGObject class]]) {
|
||||||
|
return [object toDictionary];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSException *e = [NSException
|
||||||
|
exceptionWithName:@"InvalidObjectArgumentException"
|
||||||
|
reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object]
|
||||||
|
userInfo:nil];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) parameterToString:(id)param {
|
||||||
|
if ([param isKindOfClass:[NSString class]]) {
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSNumber class]]) {
|
||||||
|
return [param stringValue];
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSDate class]]) {
|
||||||
|
return [self dateParameterToString:param];
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSArray class]]) {
|
||||||
|
NSMutableArray *mutableParam = [NSMutableArray array];
|
||||||
|
[param enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[mutableParam addObject:[self parameterToString:obj]];
|
||||||
|
}];
|
||||||
|
return [mutableParam componentsJoinedByString:@","];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSException *e = [NSException
|
||||||
|
exceptionWithName:@"InvalidObjectArgumentException"
|
||||||
|
reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", param]
|
||||||
|
userInfo:nil];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)dateParameterToString:(id)param {
|
||||||
|
return [param ISO8601String];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Utility Methods
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect `Accept` from accepts
|
||||||
|
*/
|
||||||
|
- (NSString *) selectHeaderAccept:(NSArray *)accepts {
|
||||||
|
if (accepts.count == 0) {
|
||||||
|
return @"";
|
||||||
|
}
|
||||||
|
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
|
||||||
|
for (NSString *string in accepts) {
|
||||||
|
if ([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0) {
|
||||||
|
return kApplicationJSONType;
|
||||||
|
}
|
||||||
|
[lowerAccepts addObject:[string lowercaseString]];
|
||||||
|
}
|
||||||
|
return [lowerAccepts componentsJoinedByString:@", "];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect `Content-Type` from contentTypes
|
||||||
|
*/
|
||||||
|
- (NSString *) selectHeaderContentType:(NSArray *)contentTypes {
|
||||||
|
if (contentTypes.count == 0) {
|
||||||
|
return kApplicationJSONType;
|
||||||
|
}
|
||||||
|
NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]];
|
||||||
|
for (NSString *string in contentTypes) {
|
||||||
|
if([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0){
|
||||||
|
return kApplicationJSONType;
|
||||||
|
}
|
||||||
|
[lowerContentTypes addObject:[string lowercaseString]];
|
||||||
|
}
|
||||||
|
return [lowerContentTypes firstObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,39 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "SWGObject.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@protocol SWGReturn
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface SWGReturn : SWGObject
|
||||||
|
|
||||||
|
/* property description *_/ ' \" =end \\r\\n \\n \\r [optional]
|
||||||
|
*/
|
||||||
|
@property(nonatomic) NSNumber* _return;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,34 @@
|
|||||||
|
#import "SWGReturn.h"
|
||||||
|
|
||||||
|
@implementation SWGReturn
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
// initialize property's default value, if any
|
||||||
|
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps json key to property name.
|
||||||
|
* This method is used by `JSONModel`.
|
||||||
|
*/
|
||||||
|
+ (JSONKeyMapper *)keyMapper {
|
||||||
|
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"return": @"_return" }];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the property with the given name is optional.
|
||||||
|
* If `propertyName` is optional, then return `YES`, otherwise return `NO`.
|
||||||
|
* This method is used by `JSONModel`.
|
||||||
|
*/
|
||||||
|
+ (BOOL)propertyIsOptional:(NSString *)propertyName {
|
||||||
|
|
||||||
|
NSArray *optionalProperties = @[@"_return"];
|
||||||
|
return [optionalProperties containsObject:propertyName];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,58 @@
|
|||||||
|
# SWGFakeApi
|
||||||
|
|
||||||
|
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**testCodeInjectEndRnNR**](SWGFakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
|
# **testCodeInjectEndRnNR**
|
||||||
|
```objc
|
||||||
|
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
|
||||||
|
completionHandler: (void (^)(NSError* error)) handler;
|
||||||
|
```
|
||||||
|
|
||||||
|
To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```objc
|
||||||
|
|
||||||
|
NSString* testCodeInjectEndRnNR = @"testCodeInjectEndRnNR_example"; // To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional)
|
||||||
|
|
||||||
|
SWGFakeApi*apiInstance = [[SWGFakeApi alloc] init];
|
||||||
|
|
||||||
|
// To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
[apiInstance testCodeInjectEndRnNRWithTestCodeInjectEndRnNR:testCodeInjectEndRnNR
|
||||||
|
completionHandler: ^(NSError* error) {
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"Error calling SWGFakeApi->testCodeInjectEndRnNR: %@", error);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**testCodeInjectEndRnNR** | **NSString***| To test code injection *_/ ' \" =end \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, */ ' =end
|
||||||
|
|
||||||
|
|
||||||
|
- **Accept**: application/json, */ ' =end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
10
samples/client/petstore-security-test/objc/docs/SWGReturn.md
Normal file
10
samples/client/petstore-security-test/objc/docs/SWGReturn.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# SWGReturn
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**_return** | **NSNumber*** | property description *_/ ' \" =end \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
52
samples/client/petstore-security-test/objc/git_push.sh
Normal file
52
samples/client/petstore-security-test/objc/git_push.sh
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=`git remote`
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
||||||
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
# SwaggerClient-php
|
# SwaggerClient-php
|
||||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
|
||||||
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||||
|
|
||||||
- API version: 1.0.0 */ ' " =end
|
- API version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
- Build date: 2016-07-06T12:09:22.895-07:00
|
- Build date: 2016-07-12T18:29:31.200+08:00
|
||||||
- Build package: class io.swagger.codegen.languages.PhpClientCodegen
|
- Build package: class io.swagger.codegen.languages.PhpClientCodegen
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
@ -58,12 +58,12 @@ Please follow the [installation procedure](#installation--usage) and then run th
|
|||||||
require_once(__DIR__ . '/vendor/autoload.php');
|
require_once(__DIR__ . '/vendor/autoload.php');
|
||||||
|
|
||||||
$api_instance = new Swagger\Client\Api\FakeApi();
|
$api_instance = new Swagger\Client\Api\FakeApi();
|
||||||
$test_code_inject____end = "test_code_inject____end_example"; // string | To test code injection */ ' \" =end
|
$test_code_inject____end_rn_n_r = "test_code_inject____end_rn_n_r_example"; // string | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$api_instance->testCodeInjectEnd($test_code_inject____end);
|
$api_instance->testCodeInjectEndRnNR($test_code_inject____end_rn_n_r);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo 'Exception when calling FakeApi->testCodeInjectEnd: ', $e->getMessage(), PHP_EOL;
|
echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -71,11 +71,11 @@ try {
|
|||||||
|
|
||||||
## Documentation for API Endpoints
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
|
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r*
|
||||||
|
|
||||||
Class | Method | HTTP request | Description
|
Class | Method | HTTP request | Description
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
*FakeApi* | [**testCodeInjectEnd**](docs/Api/FakeApi.md#testcodeinjectend) | **PUT** /fake | To test code injection */ ' \" =end
|
*FakeApi* | [**testCodeInjectEndRnNR**](docs/Api/FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
## Documentation For Models
|
## Documentation For Models
|
||||||
@ -86,24 +86,24 @@ Class | Method | HTTP request | Description
|
|||||||
## Documentation For Authorization
|
## Documentation For Authorization
|
||||||
|
|
||||||
|
|
||||||
|
## api_key
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key */ ' " =end \r\n \n \r
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
||||||
## petstore_auth
|
## petstore_auth
|
||||||
|
|
||||||
- **Type**: OAuth
|
- **Type**: OAuth
|
||||||
- **Flow**: implicit
|
- **Flow**: implicit
|
||||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
- **Scopes**:
|
- **Scopes**:
|
||||||
- **write:pets**: modify pets in your account */ ' " =end
|
- **write:pets**: modify pets in your account */ ' " =end \r\n \n \r
|
||||||
- **read:pets**: read your pets */ ' " =end
|
- **read:pets**: read your pets */ ' " =end \r\n \n \r
|
||||||
|
|
||||||
## api_key
|
|
||||||
|
|
||||||
- **Type**: API key
|
|
||||||
- **API key parameter name**: api_key */ ' " =end
|
|
||||||
- **Location**: HTTP header
|
|
||||||
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
apiteam@swagger.io */ ' " =end
|
apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore */ ' " =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 */ ' " =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io */ ' " =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
# Swagger\Client\FakeApi
|
# Swagger\Client\FakeApi
|
||||||
|
|
||||||
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
|
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r*
|
||||||
|
|
||||||
Method | HTTP request | Description
|
Method | HTTP request | Description
|
||||||
------------- | ------------- | -------------
|
------------- | ------------- | -------------
|
||||||
[**testCodeInjectEnd**](FakeApi.md#testCodeInjectEnd) | **PUT** /fake | To test code injection */ ' \" =end
|
[**testCodeInjectEndRnNR**](FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
# **testCodeInjectEnd**
|
# **testCodeInjectEndRnNR**
|
||||||
> testCodeInjectEnd($test_code_inject____end)
|
> testCodeInjectEndRnNR($test_code_inject____end_rn_n_r)
|
||||||
|
|
||||||
To test code injection */ ' \" =end
|
To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
```php
|
```php
|
||||||
@ -18,12 +18,12 @@ To test code injection */ ' \" =end
|
|||||||
require_once(__DIR__ . '/vendor/autoload.php');
|
require_once(__DIR__ . '/vendor/autoload.php');
|
||||||
|
|
||||||
$api_instance = new Swagger\Client\Api\FakeApi();
|
$api_instance = new Swagger\Client\Api\FakeApi();
|
||||||
$test_code_inject____end = "test_code_inject____end_example"; // string | To test code injection */ ' \" =end
|
$test_code_inject____end_rn_n_r = "test_code_inject____end_rn_n_r_example"; // string | To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$api_instance->testCodeInjectEnd($test_code_inject____end);
|
$api_instance->testCodeInjectEndRnNR($test_code_inject____end_rn_n_r);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo 'Exception when calling FakeApi->testCodeInjectEnd: ', $e->getMessage(), PHP_EOL;
|
echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
```
|
```
|
||||||
@ -32,7 +32,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**test_code_inject____end** | **string**| To test code injection */ ' \" =end | [optional]
|
**test_code_inject____end_rn_n_r** | **string**| To test code injection *_/ ' \" =end \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ No authorization required
|
|||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
- **Content-Type**: application/json, */ ' " =end
|
- **Content-Type**: application/json, *_/ \" =end
|
||||||
- **Accept**: application/json, */ ' " =end
|
- **Accept**: application/json, *_/ \" =end
|
||||||
|
|
||||||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
## Properties
|
## Properties
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**return** | **int** | property description */ ' \" =end | [optional]
|
**return** | **int** | property description *_/ ' \" =end \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore */ ' " =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 */ ' " =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io */ ' " =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -73,7 +73,7 @@ class FakeApi
|
|||||||
{
|
{
|
||||||
if ($apiClient == null) {
|
if ($apiClient == null) {
|
||||||
$apiClient = new ApiClient();
|
$apiClient = new ApiClient();
|
||||||
$apiClient->getConfig()->setHost('https://petstore.swagger.io */ ' " =end/v2 */ ' " =end');
|
$apiClient->getConfig()->setHost('https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
@ -103,30 +103,30 @@ class FakeApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation testCodeInjectEnd
|
* Operation testCodeInjectEndRnNR
|
||||||
*
|
*
|
||||||
* To test code injection */ ' \" =end
|
* To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* @param string $test_code_inject____end To test code injection */ ' \" =end (optional)
|
* @param string $test_code_inject____end_rn_n_r To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional)
|
||||||
* @return void
|
* @return void
|
||||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||||
*/
|
*/
|
||||||
public function testCodeInjectEnd($test_code_inject____end = null)
|
public function testCodeInjectEndRnNR($test_code_inject____end_rn_n_r = null)
|
||||||
{
|
{
|
||||||
list($response) = $this->testCodeInjectEndWithHttpInfo($test_code_inject____end);
|
list($response) = $this->testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end_rn_n_r);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation testCodeInjectEndWithHttpInfo
|
* Operation testCodeInjectEndRnNRWithHttpInfo
|
||||||
*
|
*
|
||||||
* To test code injection */ ' \" =end
|
* To test code injection *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* @param string $test_code_inject____end To test code injection */ ' \" =end (optional)
|
* @param string $test_code_inject____end_rn_n_r To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional)
|
||||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||||
*/
|
*/
|
||||||
public function testCodeInjectEndWithHttpInfo($test_code_inject____end = null)
|
public function testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end_rn_n_r = null)
|
||||||
{
|
{
|
||||||
// parse inputs
|
// parse inputs
|
||||||
$resourcePath = "/fake";
|
$resourcePath = "/fake";
|
||||||
@ -134,18 +134,18 @@ class FakeApi
|
|||||||
$queryParams = array();
|
$queryParams = array();
|
||||||
$headerParams = array();
|
$headerParams = array();
|
||||||
$formParams = array();
|
$formParams = array();
|
||||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', '*/ ' " =end'));
|
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', '*_/ \" =end'));
|
||||||
if (!is_null($_header_accept)) {
|
if (!is_null($_header_accept)) {
|
||||||
$headerParams['Accept'] = $_header_accept;
|
$headerParams['Accept'] = $_header_accept;
|
||||||
}
|
}
|
||||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','*/ ' " =end'));
|
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','*_/ \" =end'));
|
||||||
|
|
||||||
// default format to json
|
// default format to json
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
||||||
|
|
||||||
// form params
|
// form params
|
||||||
if ($test_code_inject____end !== null) {
|
if ($test_code_inject____end_rn_n_r !== null) {
|
||||||
$formParams['test code inject */ ' " =end'] = $this->apiClient->getSerializer()->toFormValue($test_code_inject____end);
|
$formParams['test code inject */ ' " =end \r\n \n \r'] = $this->apiClient->getSerializer()->toFormValue($test_code_inject____end_rn_n_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for model (json/xml)
|
// for model (json/xml)
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore */ ' " =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 */ ' " =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io */ ' " =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore */ ' " =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 */ ' " =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io */ ' " =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore */ ' " =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 */ ' " =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io */ ' " =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -102,7 +102,7 @@ class Configuration
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $host = 'https://petstore.swagger.io */ ' " =end/v2 */ ' " =end';
|
protected $host = 'https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timeout (second) of the HTTP request, by default set to 0, no timeout
|
* Timeout (second) of the HTTP request, by default set to 0, no timeout
|
||||||
@ -522,7 +522,7 @@ class Configuration
|
|||||||
$report = 'PHP SDK (Swagger\Client) Debug Report:' . PHP_EOL;
|
$report = 'PHP SDK (Swagger\Client) Debug Report:' . PHP_EOL;
|
||||||
$report .= ' OS: ' . php_uname() . PHP_EOL;
|
$report .= ' OS: ' . php_uname() . PHP_EOL;
|
||||||
$report .= ' PHP Version: ' . phpversion() . PHP_EOL;
|
$report .= ' PHP Version: ' . phpversion() . PHP_EOL;
|
||||||
$report .= ' OpenAPI Spec Version: 1.0.0 */ ' " =end' . PHP_EOL;
|
$report .= ' OpenAPI Spec Version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r' . PHP_EOL;
|
||||||
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
|
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
|
||||||
|
|
||||||
return $report;
|
return $report;
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore */ ' " =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 */ ' " =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io */ ' " =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -47,7 +47,7 @@ use \ArrayAccess;
|
|||||||
* ModelReturn Class Doc Comment
|
* ModelReturn Class Doc Comment
|
||||||
*
|
*
|
||||||
* @category Class */
|
* @category Class */
|
||||||
// @description Model for testing reserved words */ ' \" =end
|
// @description Model for testing reserved words *_/ ' \" =end \\r\\n \\n \\r
|
||||||
/**
|
/**
|
||||||
* @package Swagger\Client
|
* @package Swagger\Client
|
||||||
* @author http://github.com/swagger-api/swagger-codegen
|
* @author http://github.com/swagger-api/swagger-codegen
|
||||||
@ -167,7 +167,7 @@ class ModelReturn implements ArrayAccess
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets return
|
* Sets return
|
||||||
* @param int $return property description */ ' \" =end
|
* @param int $return property description *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setReturn($return)
|
public function setReturn($return)
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore */ ' " =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 */ ' " =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io */ ' " =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -264,7 +264,7 @@ class ObjectSerializer
|
|||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
|
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {
|
||||||
settype($data, $class);
|
settype($data, $class);
|
||||||
return $data;
|
return $data;
|
||||||
} elseif ($class === '\SplFileObject') {
|
} elseif ($class === '\SplFileObject') {
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore ' \" =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 ' \" =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io ' \" =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -90,12 +90,12 @@ class FakeApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case for testCodeInjectEnd
|
* Test case for testCodeInjectEndRnNR
|
||||||
*
|
*
|
||||||
* To test code injection ' \" =end.
|
* To test code injection *_/ ' \" =end \\r\\n \\n \\r.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testTestCodeInjectEnd()
|
public function testTestCodeInjectEndRnNR()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger Petstore ' \" =end
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 ' \" =end
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io ' \" =end
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -45,7 +45,7 @@ namespace Swagger\Client;
|
|||||||
* ModelReturnTest Class Doc Comment
|
* ModelReturnTest Class Doc Comment
|
||||||
*
|
*
|
||||||
* @category Class */
|
* @category Class */
|
||||||
// * @description Model for testing reserved words ' \" =end
|
// * @description Model for testing reserved words *_/ ' \" =end \\r\\n \\n \\r
|
||||||
/**
|
/**
|
||||||
* @package Swagger\Client
|
* @package Swagger\Client
|
||||||
* @author http://github.com/swagger-api/swagger-codegen
|
* @author http://github.com/swagger-api/swagger-codegen
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
# Swagger Codegen Ignore
|
||||||
|
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
201
samples/client/petstore-security-test/qt5cpp/LICENSE
Normal file
201
samples/client/petstore-security-test/qt5cpp/LICENSE
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SWGFakeApi.h"
|
||||||
|
#include "SWGHelpers.h"
|
||||||
|
#include "SWGModelFactory.h"
|
||||||
|
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
SWGFakeApi::SWGFakeApi() {}
|
||||||
|
|
||||||
|
SWGFakeApi::~SWGFakeApi() {}
|
||||||
|
|
||||||
|
SWGFakeApi::SWGFakeApi(QString host, QString basePath) {
|
||||||
|
this->host = host;
|
||||||
|
this->basePath = basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGFakeApi::testCodeInject */ ' " =end \r\n \n \r(QString* test code inject */ ' " =end \r\n \n \r) {
|
||||||
|
QString fullPath;
|
||||||
|
fullPath.append(this->host).append(this->basePath).append("/fake");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
|
HttpRequestInput input(fullPath, "PUT");
|
||||||
|
|
||||||
|
if (test code inject */ ' " =end \r\n \n \r != NULL) {
|
||||||
|
input.add_var("test code inject */ ' " =end \r\n \n \r", *test code inject */ ' " =end \r\n \n \r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
connect(worker,
|
||||||
|
&HttpRequestWorker::on_execution_finished,
|
||||||
|
this,
|
||||||
|
&SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback);
|
||||||
|
|
||||||
|
worker->execute(&input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpRequestWorker * worker) {
|
||||||
|
QString msg;
|
||||||
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = "Error: " + worker->error_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
worker->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
|
emit testCodeInject */ ' " =end \r\n \n \rSignal();
|
||||||
|
}
|
||||||
|
} /* namespace Swagger */
|
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SWG_SWGFakeApi_H_
|
||||||
|
#define _SWG_SWGFakeApi_H_
|
||||||
|
|
||||||
|
#include "SWGHttpRequest.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
|
||||||
|
class SWGFakeApi: public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SWGFakeApi();
|
||||||
|
SWGFakeApi(QString host, QString basePath);
|
||||||
|
~SWGFakeApi();
|
||||||
|
|
||||||
|
QString host;
|
||||||
|
QString basePath;
|
||||||
|
|
||||||
|
void testCodeInject */ ' " =end \r\n \n \r(QString* test code inject */ ' " =end \r\n \n \r);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void testCodeInject */ ' " =end \r\n \n \rCallback (HttpRequestWorker * worker);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void testCodeInject */ ' " =end \r\n \n \rSignal();
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
@ -0,0 +1,279 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SWGHelpers.h"
|
||||||
|
#include "SWGModelFactory.h"
|
||||||
|
#include "SWGObject.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
|
||||||
|
void
|
||||||
|
setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
||||||
|
if(value == NULL) {
|
||||||
|
// can't set value with a null pointer
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(QStringLiteral("bool").compare(type) == 0) {
|
||||||
|
bool * val = static_cast<bool*>(value);
|
||||||
|
*val = obj.toBool();
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||||
|
qint32 *val = static_cast<qint32*>(value);
|
||||||
|
*val = obj.toInt();
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||||
|
qint64 *val = static_cast<qint64*>(value);
|
||||||
|
*val = obj.toVariant().toLongLong();
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("float").compare(type) == 0) {
|
||||||
|
float *val = static_cast<float*>(value);
|
||||||
|
*val = obj.toDouble();
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("double").compare(type) == 0) {
|
||||||
|
double *val = static_cast<double*>(value);
|
||||||
|
*val = obj.toDouble();
|
||||||
|
}
|
||||||
|
else if (QStringLiteral("QString").compare(type) == 0) {
|
||||||
|
QString **val = static_cast<QString**>(value);
|
||||||
|
|
||||||
|
if(val != NULL) {
|
||||||
|
if(!obj.isNull()) {
|
||||||
|
// create a new value and return
|
||||||
|
delete *val;
|
||||||
|
*val = new QString(obj.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// set target to NULL
|
||||||
|
delete *val;
|
||||||
|
*val = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Can't set value because the target pointer is NULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (QStringLiteral("QDateTime").compare(type) == 0) {
|
||||||
|
QDateTime **val = static_cast<QDateTime**>(value);
|
||||||
|
|
||||||
|
if(val != NULL) {
|
||||||
|
if(!obj.isNull()) {
|
||||||
|
// create a new value and return
|
||||||
|
delete *val;
|
||||||
|
*val = new QDateTime(QDateTime::fromString(obj.toString(), Qt::ISODate));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// set target to NULL
|
||||||
|
delete *val;
|
||||||
|
*val = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Can't set value because the target pointer is NULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (QStringLiteral("QDate").compare(type) == 0) {
|
||||||
|
QDate **val = static_cast<QDate**>(value);
|
||||||
|
|
||||||
|
if(val != NULL) {
|
||||||
|
if(!obj.isNull()) {
|
||||||
|
// create a new value and return
|
||||||
|
delete *val;
|
||||||
|
*val = new QDate(QDate::fromString(obj.toString(), Qt::ISODate));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// set target to NULL
|
||||||
|
delete *val;
|
||||||
|
*val = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Can't set value because the target pointer is NULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(type.startsWith("SWG") && obj.isObject()) {
|
||||||
|
// complex type
|
||||||
|
QJsonObject jsonObj = obj.toObject();
|
||||||
|
SWGObject * so = (SWGObject*)Swagger::create(type);
|
||||||
|
if(so != NULL) {
|
||||||
|
so->fromJsonObject(jsonObj);
|
||||||
|
SWGObject **val = static_cast<SWGObject**>(value);
|
||||||
|
delete *val;
|
||||||
|
*val = so;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
|
||||||
|
// list of values
|
||||||
|
QList<void*>* output = new QList<void*>();
|
||||||
|
QJsonArray arr = obj.toArray();
|
||||||
|
foreach (const QJsonValue & jval, arr) {
|
||||||
|
if(complexType.startsWith("SWG")) {
|
||||||
|
// it's an object
|
||||||
|
SWGObject * val = (SWGObject*)create(complexType);
|
||||||
|
QJsonObject t = jval.toObject();
|
||||||
|
|
||||||
|
val->fromJsonObject(t);
|
||||||
|
output->append(val);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// primitives
|
||||||
|
if(QStringLiteral("qint32").compare(complexType) == 0) {
|
||||||
|
qint32 val;
|
||||||
|
setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("qint64").compare(complexType) == 0) {
|
||||||
|
qint64 val;
|
||||||
|
setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("bool").compare(complexType) == 0) {
|
||||||
|
bool val;
|
||||||
|
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("float").compare(complexType) == 0) {
|
||||||
|
float val;
|
||||||
|
setValue(&val, jval, QStringLiteral("float"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("double").compare(complexType) == 0) {
|
||||||
|
double val;
|
||||||
|
setValue(&val, jval, QStringLiteral("double"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("QString").compare(complexType) == 0) {
|
||||||
|
QString val;
|
||||||
|
setValue(&val, jval, QStringLiteral("QString"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("QDate").compare(complexType) == 0) {
|
||||||
|
QDate val;
|
||||||
|
setValue(&val, jval, QStringLiteral("QDate"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("QDateTime").compare(complexType) == 0) {
|
||||||
|
QDateTime val;
|
||||||
|
setValue(&val, jval, QStringLiteral("QDateTime"), QStringLiteral(""));
|
||||||
|
output->append((void*)&val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QList<void*> **val = static_cast<QList<void*>**>(value);
|
||||||
|
delete *val;
|
||||||
|
*val = output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
||||||
|
if(value == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(type.startsWith("SWG")) {
|
||||||
|
SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
|
||||||
|
if(swgObject != NULL) {
|
||||||
|
QJsonObject* o = (*swgObject).asJsonObject();
|
||||||
|
if(name != NULL) {
|
||||||
|
output->insert(name, *o);
|
||||||
|
delete o;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output->empty();
|
||||||
|
foreach(QString key, o->keys()) {
|
||||||
|
output->insert(key, o->value(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("QString").compare(type) == 0) {
|
||||||
|
QString* str = static_cast<QString*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||||
|
qint32* str = static_cast<qint32*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||||
|
qint64* str = static_cast<qint64*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("bool").compare(type) == 0) {
|
||||||
|
bool* str = static_cast<bool*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("float").compare(type) == 0) {
|
||||||
|
float* str = static_cast<float*>(value);
|
||||||
|
output->insert(name, QJsonValue((double)*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("double").compare(type) == 0) {
|
||||||
|
double* str = static_cast<double*>(value);
|
||||||
|
output->insert(name, QJsonValue(*str));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("QDate").compare(type) == 0) {
|
||||||
|
QDate* date = static_cast<QDate*>(value);
|
||||||
|
output->insert(name, QJsonValue(date->toString(Qt::ISODate)));
|
||||||
|
}
|
||||||
|
else if(QStringLiteral("QDateTime").compare(type) == 0) {
|
||||||
|
QDateTime* datetime = static_cast<QDateTime*>(value);
|
||||||
|
output->insert(name, QJsonValue(datetime->toString(Qt::ISODate)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||||
|
foreach(void* obj, *value) {
|
||||||
|
QJsonObject element;
|
||||||
|
|
||||||
|
toJsonValue(NULL, obj, &element, innerType);
|
||||||
|
output->append(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
stringValue(QString* value) {
|
||||||
|
QString* str = static_cast<QString*>(value);
|
||||||
|
return QString(*str);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
stringValue(qint32 value) {
|
||||||
|
return QString::number(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
stringValue(qint64 value) {
|
||||||
|
return QString::number(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
stringValue(bool value) {
|
||||||
|
return QString(value ? "true" : "false");
|
||||||
|
}
|
||||||
|
} /* namespace Swagger */
|
@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SWGHELPERS_H
|
||||||
|
#define SWGHELPERS_H
|
||||||
|
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
void setValue(void* value, QJsonValue obj, QString type, QString complexType);
|
||||||
|
void toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType);
|
||||||
|
void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
|
||||||
|
bool isCompatibleJsonValue(QString type);
|
||||||
|
QString stringValue(QString* value);
|
||||||
|
QString stringValue(qint32 value);
|
||||||
|
QString stringValue(qint64 value);
|
||||||
|
QString stringValue(bool value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SWGHELPERS_H
|
@ -0,0 +1,323 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SWGHttpRequest.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
|
|
||||||
|
HttpRequestInput::HttpRequestInput() {
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpRequestInput::HttpRequestInput(QString v_url_str, QString v_http_method) {
|
||||||
|
initialize();
|
||||||
|
url_str = v_url_str;
|
||||||
|
http_method = v_http_method;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpRequestInput::initialize() {
|
||||||
|
var_layout = NOT_SET;
|
||||||
|
url_str = "";
|
||||||
|
http_method = "GET";
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpRequestInput::add_var(QString key, QString value) {
|
||||||
|
vars[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
|
||||||
|
SWGHttpRequestInputFileElement file;
|
||||||
|
file.variable_name = variable_name;
|
||||||
|
file.local_filename = local_filename;
|
||||||
|
file.request_filename = request_filename;
|
||||||
|
file.mime_type = mime_type;
|
||||||
|
files.append(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HttpRequestWorker::HttpRequestWorker(QObject *parent)
|
||||||
|
: QObject(parent), manager(NULL)
|
||||||
|
{
|
||||||
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
|
|
||||||
|
manager = new QNetworkAccessManager(this);
|
||||||
|
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_manager_finished(QNetworkReply*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpRequestWorker::~HttpRequestWorker() {
|
||||||
|
}
|
||||||
|
|
||||||
|
QString HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
|
||||||
|
// result structure follows RFC 5987
|
||||||
|
bool need_utf_encoding = false;
|
||||||
|
QString result = "";
|
||||||
|
QByteArray input_c = input.toLocal8Bit();
|
||||||
|
char c;
|
||||||
|
for (int i = 0; i < input_c.length(); i++) {
|
||||||
|
c = input_c.at(i);
|
||||||
|
if (c == '\\' || c == '/' || c == '\0' || c < ' ' || c > '~') {
|
||||||
|
// ignore and request utf-8 version
|
||||||
|
need_utf_encoding = true;
|
||||||
|
}
|
||||||
|
else if (c == '"') {
|
||||||
|
result += "\\\"";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.length() == 0) {
|
||||||
|
need_utf_encoding = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!need_utf_encoding) {
|
||||||
|
// return simple version
|
||||||
|
return QString("%1=\"%2\"").arg(attribute_name, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString result_utf8 = "";
|
||||||
|
for (int i = 0; i < input_c.length(); i++) {
|
||||||
|
c = input_c.at(i);
|
||||||
|
if (
|
||||||
|
(c >= '0' && c <= '9')
|
||||||
|
|| (c >= 'A' && c <= 'Z')
|
||||||
|
|| (c >= 'a' && c <= 'z')
|
||||||
|
) {
|
||||||
|
result_utf8 += c;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result_utf8 += "%" + QString::number(static_cast<unsigned char>(input_c.at(i)), 16).toUpper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return enhanced version with UTF-8 support
|
||||||
|
return QString("%1=\"%2\"; %1*=utf-8''%3").arg(attribute_name, result, result_utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpRequestWorker::execute(HttpRequestInput *input) {
|
||||||
|
|
||||||
|
// reset variables
|
||||||
|
|
||||||
|
QByteArray request_content = "";
|
||||||
|
response = "";
|
||||||
|
error_type = QNetworkReply::NoError;
|
||||||
|
error_str = "";
|
||||||
|
bool isFormData = false;
|
||||||
|
|
||||||
|
|
||||||
|
// decide on the variable layout
|
||||||
|
|
||||||
|
if (input->files.length() > 0) {
|
||||||
|
input->var_layout = MULTIPART;
|
||||||
|
}
|
||||||
|
if (input->var_layout == NOT_SET) {
|
||||||
|
input->var_layout = input->http_method == "GET" || input->http_method == "HEAD" ? ADDRESS : URL_ENCODED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// prepare request content
|
||||||
|
|
||||||
|
QString boundary = "";
|
||||||
|
|
||||||
|
if (input->var_layout == ADDRESS || input->var_layout == URL_ENCODED) {
|
||||||
|
// variable layout is ADDRESS or URL_ENCODED
|
||||||
|
|
||||||
|
if (input->vars.count() > 0) {
|
||||||
|
bool first = true;
|
||||||
|
isFormData = true;
|
||||||
|
foreach (QString key, input->vars.keys()) {
|
||||||
|
if (!first) {
|
||||||
|
request_content.append("&");
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
|
||||||
|
request_content.append(QUrl::toPercentEncoding(key));
|
||||||
|
request_content.append("=");
|
||||||
|
request_content.append(QUrl::toPercentEncoding(input->vars.value(key)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input->var_layout == ADDRESS) {
|
||||||
|
input->url_str += "?" + request_content;
|
||||||
|
request_content = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// variable layout is MULTIPART
|
||||||
|
|
||||||
|
boundary = "__-----------------------"
|
||||||
|
+ QString::number(QDateTime::currentDateTime().toTime_t())
|
||||||
|
+ QString::number(qrand());
|
||||||
|
QString boundary_delimiter = "--";
|
||||||
|
QString new_line = "\r\n";
|
||||||
|
|
||||||
|
// add variables
|
||||||
|
foreach (QString key, input->vars.keys()) {
|
||||||
|
// add boundary
|
||||||
|
request_content.append(boundary_delimiter);
|
||||||
|
request_content.append(boundary);
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
// add header
|
||||||
|
request_content.append("Content-Disposition: form-data; ");
|
||||||
|
request_content.append(http_attribute_encode("name", key));
|
||||||
|
request_content.append(new_line);
|
||||||
|
request_content.append("Content-Type: text/plain");
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
// add header to body splitter
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
// add variable content
|
||||||
|
request_content.append(input->vars.value(key));
|
||||||
|
request_content.append(new_line);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add files
|
||||||
|
for (QList<SWGHttpRequestInputFileElement>::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) {
|
||||||
|
QFileInfo fi(file_info->local_filename);
|
||||||
|
|
||||||
|
// ensure necessary variables are available
|
||||||
|
if (
|
||||||
|
file_info->local_filename == NULL || file_info->local_filename.isEmpty()
|
||||||
|
|| file_info->variable_name == NULL || file_info->variable_name.isEmpty()
|
||||||
|
|| !fi.exists() || !fi.isFile() || !fi.isReadable()
|
||||||
|
) {
|
||||||
|
// silent abort for the current file
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(file_info->local_filename);
|
||||||
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
// silent abort for the current file
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure filename for the request
|
||||||
|
if (file_info->request_filename == NULL || file_info->request_filename.isEmpty()) {
|
||||||
|
file_info->request_filename = fi.fileName();
|
||||||
|
if (file_info->request_filename.isEmpty()) {
|
||||||
|
file_info->request_filename = "file";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add boundary
|
||||||
|
request_content.append(boundary_delimiter);
|
||||||
|
request_content.append(boundary);
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
// add header
|
||||||
|
request_content.append(QString("Content-Disposition: form-data; %1; %2").arg(
|
||||||
|
http_attribute_encode("name", file_info->variable_name),
|
||||||
|
http_attribute_encode("filename", file_info->request_filename)
|
||||||
|
));
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
if (file_info->mime_type != NULL && !file_info->mime_type.isEmpty()) {
|
||||||
|
request_content.append("Content-Type: ");
|
||||||
|
request_content.append(file_info->mime_type);
|
||||||
|
request_content.append(new_line);
|
||||||
|
}
|
||||||
|
|
||||||
|
request_content.append("Content-Transfer-Encoding: binary");
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
// add header to body splitter
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
// add file content
|
||||||
|
request_content.append(file.readAll());
|
||||||
|
request_content.append(new_line);
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add end of body
|
||||||
|
request_content.append(boundary_delimiter);
|
||||||
|
request_content.append(boundary);
|
||||||
|
request_content.append(boundary_delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(input->request_body.size() > 0) {
|
||||||
|
qDebug() << "got a request body";
|
||||||
|
request_content.clear();
|
||||||
|
request_content.append(input->request_body);
|
||||||
|
}
|
||||||
|
// prepare connection
|
||||||
|
|
||||||
|
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
||||||
|
request.setRawHeader("User-Agent", "Swagger-Client");
|
||||||
|
foreach(QString key, input->headers.keys()) {
|
||||||
|
request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request_content.size() > 0 && !isFormData) {
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
|
}
|
||||||
|
else if (input->var_layout == URL_ENCODED) {
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
}
|
||||||
|
else if (input->var_layout == MULTIPART) {
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input->http_method == "GET") {
|
||||||
|
manager->get(request);
|
||||||
|
}
|
||||||
|
else if (input->http_method == "POST") {
|
||||||
|
manager->post(request, request_content);
|
||||||
|
}
|
||||||
|
else if (input->http_method == "PUT") {
|
||||||
|
manager->put(request, request_content);
|
||||||
|
}
|
||||||
|
else if (input->http_method == "HEAD") {
|
||||||
|
manager->head(request);
|
||||||
|
}
|
||||||
|
else if (input->http_method == "DELETE") {
|
||||||
|
manager->deleteResource(request);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QBuffer buff(&request_content);
|
||||||
|
manager->sendCustomRequest(request, input->http_method.toLatin1(), &buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
|
||||||
|
error_type = reply->error();
|
||||||
|
if (error_type == QNetworkReply::NoError) {
|
||||||
|
response = reply->readAll();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error_str = reply->errorString();
|
||||||
|
}
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
emit on_execution_finished(this);
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on http://www.creativepulse.gr/en/blog/2014/restful-api-requests-using-qt-cpp-for-linux-mac-osx-ms-windows
|
||||||
|
* By Alex Stylianos
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef HTTPREQUESTWORKER_H
|
||||||
|
#define HTTPREQUESTWORKER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
|
||||||
|
|
||||||
|
|
||||||
|
class SWGHttpRequestInputFileElement {
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString variable_name;
|
||||||
|
QString local_filename;
|
||||||
|
QString request_filename;
|
||||||
|
QString mime_type;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class HttpRequestInput {
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString url_str;
|
||||||
|
QString http_method;
|
||||||
|
HttpRequestVarLayout var_layout;
|
||||||
|
QMap<QString, QString> vars;
|
||||||
|
QMap<QString, QString> headers;
|
||||||
|
QList<SWGHttpRequestInputFileElement> files;
|
||||||
|
QByteArray request_body;
|
||||||
|
|
||||||
|
HttpRequestInput();
|
||||||
|
HttpRequestInput(QString v_url_str, QString v_http_method);
|
||||||
|
void initialize();
|
||||||
|
void add_var(QString key, QString value);
|
||||||
|
void add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class HttpRequestWorker : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QByteArray response;
|
||||||
|
QNetworkReply::NetworkError error_type;
|
||||||
|
QString error_str;
|
||||||
|
|
||||||
|
explicit HttpRequestWorker(QObject *parent = 0);
|
||||||
|
virtual ~HttpRequestWorker();
|
||||||
|
|
||||||
|
QString http_attribute_encode(QString attribute_name, QString input);
|
||||||
|
void execute(HttpRequestInput *input);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void on_execution_finished(HttpRequestWorker *worker);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkAccessManager *manager;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_manager_finished(QNetworkReply *reply);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HTTPREQUESTWORKER_H
|
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ModelFactory_H_
|
||||||
|
#define ModelFactory_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "SWGReturn.h"
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
inline void* create(QString type) {
|
||||||
|
if(QString("SWGReturn").compare(type) == 0) {
|
||||||
|
return new SWGReturn();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* create(QString json, QString type) {
|
||||||
|
void* val = create(type);
|
||||||
|
if(val != NULL) {
|
||||||
|
SWGObject* obj = static_cast<SWGObject*>(val);
|
||||||
|
return obj->fromJson(json);
|
||||||
|
}
|
||||||
|
if(type.startsWith("QString")) {
|
||||||
|
return new QString();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} /* namespace Swagger */
|
||||||
|
|
||||||
|
#endif /* ModelFactory_H_ */
|
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SWG_OBJECT_H_
|
||||||
|
#define _SWG_OBJECT_H_
|
||||||
|
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
class SWGObject {
|
||||||
|
public:
|
||||||
|
virtual QJsonObject* asJsonObject() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
virtual ~SWGObject() {}
|
||||||
|
virtual SWGObject* fromJson(QString &jsonString) {
|
||||||
|
Q_UNUSED(jsonString);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
virtual void fromJsonObject(QJsonObject &json) {
|
||||||
|
Q_UNUSED(json);
|
||||||
|
}
|
||||||
|
virtual QString asJson() {
|
||||||
|
return QString("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _SWG_OBJECT_H_ */
|
@ -0,0 +1,105 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "SWGReturn.h"
|
||||||
|
|
||||||
|
#include "SWGHelpers.h"
|
||||||
|
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
|
||||||
|
|
||||||
|
SWGReturn::SWGReturn(QString* json) {
|
||||||
|
init();
|
||||||
|
this->fromJson(*json);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWGReturn::SWGReturn() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
SWGReturn::~SWGReturn() {
|
||||||
|
this->cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGReturn::init() {
|
||||||
|
return = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGReturn::cleanup() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SWGReturn*
|
||||||
|
SWGReturn::fromJson(QString &json) {
|
||||||
|
QByteArray array (json.toStdString().c_str());
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||||
|
QJsonObject jsonObject = doc.object();
|
||||||
|
this->fromJsonObject(jsonObject);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SWGReturn::fromJsonObject(QJsonObject &pJson) {
|
||||||
|
setValue(&return, pJson["return"], "qint32", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
SWGReturn::asJson ()
|
||||||
|
{
|
||||||
|
QJsonObject* obj = this->asJsonObject();
|
||||||
|
|
||||||
|
QJsonDocument doc(*obj);
|
||||||
|
QByteArray bytes = doc.toJson();
|
||||||
|
return QString(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject*
|
||||||
|
SWGReturn::asJsonObject() {
|
||||||
|
QJsonObject* obj = new QJsonObject();
|
||||||
|
obj->insert("return", QJsonValue(return));
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32
|
||||||
|
SWGReturn::getReturn() {
|
||||||
|
return return;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
SWGReturn::setReturn(qint32 return) {
|
||||||
|
this->return = return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace Swagger */
|
||||||
|
|
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SWGReturn.h
|
||||||
|
*
|
||||||
|
* Model for testing reserved words *_/ ' \" =end \\r\\n \\n \\r
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SWGReturn_H_
|
||||||
|
#define SWGReturn_H_
|
||||||
|
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "SWGObject.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Swagger {
|
||||||
|
|
||||||
|
class SWGReturn: public SWGObject {
|
||||||
|
public:
|
||||||
|
SWGReturn();
|
||||||
|
SWGReturn(QString* json);
|
||||||
|
virtual ~SWGReturn();
|
||||||
|
void init();
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
QString asJson ();
|
||||||
|
QJsonObject* asJsonObject();
|
||||||
|
void fromJsonObject(QJsonObject &json);
|
||||||
|
SWGReturn* fromJson(QString &jsonString);
|
||||||
|
|
||||||
|
qint32 getReturn();
|
||||||
|
void setReturn(qint32 return);
|
||||||
|
|
||||||
|
private:
|
||||||
|
qint32 return;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace Swagger */
|
||||||
|
|
||||||
|
#endif /* SWGReturn_H_ */
|
17
samples/client/petstore-security-test/scala/.gitignore
vendored
Normal file
17
samples/client/petstore-security-test/scala/.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
*.class
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# sbt specific
|
||||||
|
.cache
|
||||||
|
.history
|
||||||
|
.lib/
|
||||||
|
dist/*
|
||||||
|
target/
|
||||||
|
lib_managed/
|
||||||
|
src_managed/
|
||||||
|
project/boot/
|
||||||
|
project/plugins/project/
|
||||||
|
|
||||||
|
# Scala-IDE specific
|
||||||
|
.scala_dependencies
|
||||||
|
.worksheet
|
@ -0,0 +1,23 @@
|
|||||||
|
# Swagger Codegen Ignore
|
||||||
|
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
201
samples/client/petstore-security-test/scala/LICENSE
Normal file
201
samples/client/petstore-security-test/scala/LICENSE
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
120
samples/client/petstore-security-test/scala/build.gradle
Normal file
120
samples/client/petstore-security-test/scala/build.gradle
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'eclipse'
|
||||||
|
|
||||||
|
group = 'io.swagger'
|
||||||
|
version = '1.0.0'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:1.5.+'
|
||||||
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(hasProperty('target') && target == 'android') {
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 23
|
||||||
|
buildToolsVersion '23.0.2'
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 14
|
||||||
|
targetSdkVersion 23
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename the aar correctly
|
||||||
|
libraryVariants.all { variant ->
|
||||||
|
variant.outputs.each { output ->
|
||||||
|
def outputFile = output.outputFile
|
||||||
|
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||||
|
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||||
|
output.outputFile = new File(outputFile.parent, fileName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
provided 'javax.annotation:jsr250-api:1.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
android.libraryVariants.all { variant ->
|
||||||
|
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||||
|
task.description = "Create jar artifact for ${variant.name}"
|
||||||
|
task.dependsOn variant.javaCompile
|
||||||
|
task.from variant.javaCompile.destinationDir
|
||||||
|
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||||
|
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||||
|
artifacts.add('archives', task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar) {
|
||||||
|
from android.sourceSets.main.java.srcDirs
|
||||||
|
classifier = 'sources'
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
apply plugin: 'scala'
|
||||||
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'maven'
|
||||||
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
|
|
||||||
|
install {
|
||||||
|
repositories.mavenInstaller {
|
||||||
|
pom.artifactId = 'swagger-scala-client'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task execute(type:JavaExec) {
|
||||||
|
main = System.getProperty('mainClass')
|
||||||
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
scala_version = "2.10.4"
|
||||||
|
joda_version = "1.2"
|
||||||
|
jodatime_version = "2.2"
|
||||||
|
jersey_version = "1.19"
|
||||||
|
swagger_core_version = "1.5.8"
|
||||||
|
jersey_async_version = "1.0.5"
|
||||||
|
jackson_version = "2.4.2"
|
||||||
|
junit_version = "4.8.1"
|
||||||
|
scala_test_version = "2.2.4"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "com.fasterxml.jackson.module:jackson-module-scala_2.10:$jackson_version"
|
||||||
|
compile "com.sun.jersey:jersey-client:$jersey_version"
|
||||||
|
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
|
||||||
|
compile "org.jfarcand:jersey-ahc-client:$jersey_async_version"
|
||||||
|
compile "org.scala-lang:scala-library:$scala_version"
|
||||||
|
compile "io.swagger:swagger-core:$swagger_core_version"
|
||||||
|
testCompile "org.scalatest:scalatest_2.10:$scala_test_version"
|
||||||
|
testCompile "junit:junit:$junit_version"
|
||||||
|
compile "joda-time:joda-time:$jodatime_version"
|
||||||
|
compile "org.joda:joda-convert:$joda_version"
|
||||||
|
}
|
33
samples/client/petstore-security-test/scala/build.sbt
Normal file
33
samples/client/petstore-security-test/scala/build.sbt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
lazy val root = (project in file(".")).
|
||||||
|
settings(
|
||||||
|
version := "1.0.0",
|
||||||
|
name := "swagger-scala-client",
|
||||||
|
organization := "io.swagger",
|
||||||
|
scalaVersion := "2.11.8",
|
||||||
|
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.4.2",
|
||||||
|
"com.sun.jersey" % "jersey-core" % "1.19",
|
||||||
|
"com.sun.jersey" % "jersey-client" % "1.19",
|
||||||
|
"com.sun.jersey.contribs" % "jersey-multipart" % "1.19",
|
||||||
|
"org.jfarcand" % "jersey-ahc-client" % "1.0.5",
|
||||||
|
"io.swagger" % "swagger-core" % "1.5.8",
|
||||||
|
"joda-time" % "joda-time" % "2.2",
|
||||||
|
"org.joda" % "joda-convert" % "1.2",
|
||||||
|
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
|
||||||
|
"junit" % "junit" % "4.8.1" % "test"
|
||||||
|
),
|
||||||
|
|
||||||
|
resolvers ++= Seq(
|
||||||
|
Resolver.jcenterRepo,
|
||||||
|
Resolver.mavenLocal
|
||||||
|
),
|
||||||
|
|
||||||
|
scalacOptions := Seq(
|
||||||
|
"-unchecked",
|
||||||
|
"-deprecation",
|
||||||
|
"-feature"
|
||||||
|
),
|
||||||
|
|
||||||
|
publishArtifact in (Compile, packageDoc) := false
|
||||||
|
)
|
52
samples/client/petstore-security-test/scala/git_push.sh
Normal file
52
samples/client/petstore-security-test/scala/git_push.sh
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=`git remote`
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
||||||
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
# Uncomment to build for Android
|
||||||
|
#target = android
|
BIN
samples/client/petstore-security-test/scala/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
samples/client/petstore-security-test/scala/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
samples/client/petstore-security-test/scala/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
samples/client/petstore-security-test/scala/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#Tue May 17 23:08:05 CST 2016
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
|
160
samples/client/petstore-security-test/scala/gradlew
vendored
Normal file
160
samples/client/petstore-security-test/scala/gradlew
vendored
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
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.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
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, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; 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=$((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
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
samples/client/petstore-security-test/scala/gradlew.bat
vendored
Normal file
90
samples/client/petstore-security-test/scala/gradlew.bat
vendored
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
@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=
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
if "%@eval[2+2]" == "4" goto 4NT_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=%*
|
||||||
|
goto execute
|
||||||
|
|
||||||
|
:4NT_args
|
||||||
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@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%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
224
samples/client/petstore-security-test/scala/pom.xml
Normal file
224
samples/client/petstore-security-test/scala/pom.xml
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-scala-client</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>swagger-scala-client</name>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<prerequisites>
|
||||||
|
<maven>2.2.0</maven>
|
||||||
|
</prerequisites>
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>maven-mongodb-plugin-repo</id>
|
||||||
|
<name>maven mongodb plugin repository</name>
|
||||||
|
<url>http://maven-mongodb-plugin.googlecode.com/svn/maven/repo</url>
|
||||||
|
<layout>default</layout>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.12</version>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>loggerPath</name>
|
||||||
|
<value>conf/log4j.properties</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
<argLine>-Xms512m -Xmx1500m</argLine>
|
||||||
|
<parallel>methods</parallel>
|
||||||
|
<forkMode>pertest</forkMode>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- attach test jar -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>2.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
<goal>test-jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<version>1.9.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>add_sources</id>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>src/main/java</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>add_test_sources</id>
|
||||||
|
<phase>generate-test-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-test-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>src/test/java</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>2.3.2</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.alchim31.maven</groupId>
|
||||||
|
<artifactId>scala-maven-plugin</artifactId>
|
||||||
|
<version>${scala-maven-plugin-version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>scala-compile-first</id>
|
||||||
|
<phase>process-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-source</goal>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>scala-test-compile</id>
|
||||||
|
<phase>process-test-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmArgs>
|
||||||
|
<jvmArg>-Xms128m</jvmArg>
|
||||||
|
<jvmArg>-Xmx1500m</jvmArg>
|
||||||
|
</jvmArgs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.scala-tools</groupId>
|
||||||
|
<artifactId>maven-scala-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<scalaVersion>${scala-version}</scalaVersion>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
|
<artifactId>jackson-module-scala_2.10</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-client</artifactId>
|
||||||
|
<version>${jersey-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.jersey.contribs</groupId>
|
||||||
|
<artifactId>jersey-multipart</artifactId>
|
||||||
|
<version>${jersey-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jfarcand</groupId>
|
||||||
|
<artifactId>jersey-ahc-client</artifactId>
|
||||||
|
<version>${jersey-async-version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.scala-lang</groupId>
|
||||||
|
<artifactId>scala-library</artifactId>
|
||||||
|
<version>${scala-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-core</artifactId>
|
||||||
|
<version>${swagger-core-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.scalatest</groupId>
|
||||||
|
<artifactId>scalatest_2.10</artifactId>
|
||||||
|
<version>${scala-test-version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit-version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>joda-time</groupId>
|
||||||
|
<artifactId>joda-time</artifactId>
|
||||||
|
<version>${joda-time-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.joda</groupId>
|
||||||
|
<artifactId>joda-convert</artifactId>
|
||||||
|
<version>${joda-version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<properties>
|
||||||
|
<scala-version>2.10.4</scala-version>
|
||||||
|
<joda-version>1.2</joda-version>
|
||||||
|
<joda-time-version>2.2</joda-time-version>
|
||||||
|
<jersey-version>1.19</jersey-version>
|
||||||
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
|
<jersey-async-version>1.0.5</jersey-async-version>
|
||||||
|
<maven-plugin.version>1.0.0</maven-plugin.version>
|
||||||
|
<jackson-version>2.4.2</jackson-version>
|
||||||
|
|
||||||
|
<junit-version>4.8.1</junit-version>
|
||||||
|
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
|
||||||
|
<scala-test-version>2.2.4</scala-test-version>
|
||||||
|
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
</project>
|
@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "swagger-scala-client"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user