forked from loafle/openapi-generator-original
Merge branch '2.3.0' into wing328-ts_angular2_typings
This commit is contained in:
commit
ed11da25fc
1
.gitignore
vendored
1
.gitignore
vendored
@ -80,6 +80,7 @@ samples/client/petstore/java/default/build/
|
|||||||
samples/client/petstore/scala/build/
|
samples/client/petstore/scala/build/
|
||||||
samples/client/petstore/java/resttemplate/hello.txt
|
samples/client/petstore/java/resttemplate/hello.txt
|
||||||
samples/client/petstore/java/retrofit2/hello.txt
|
samples/client/petstore/java/retrofit2/hello.txt
|
||||||
|
samples/client/petstore/java/feign/hello.txt
|
||||||
|
|
||||||
#PHP
|
#PHP
|
||||||
samples/client/petstore/php/SwaggerClient-php/composer.lock
|
samples/client/petstore/php/SwaggerClient-php/composer.lock
|
||||||
|
@ -77,8 +77,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
|||||||
|
|
||||||
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
|
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
|
||||||
-------------------------- | ------------ | -------------------------- | -----
|
-------------------------- | ------------ | -------------------------- | -----
|
||||||
2.3.0 (upcoming minor release) | Apr/May 2017 | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes
|
2.3.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen/2.3.0-SNAPSHOT/)| Jul/Aug 2017 | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes
|
||||||
2.2.3 (upcoming patch release) | TBD | 1.0, 1.1, 1.2, 2.0 | Patch release without breaking changes
|
2.2.3 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen/2.2.3-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0 | Patch release without breaking changes
|
||||||
[2.2.2](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.2) (**current stable**) | 2017-03-01 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.2](https://github.com/swagger-api/swagger-codegen/tree/v2.2.2)
|
[2.2.2](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.2) (**current stable**) | 2017-03-01 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.2](https://github.com/swagger-api/swagger-codegen/tree/v2.2.2)
|
||||||
[2.2.1](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.1) | 2016-08-07 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.1](https://github.com/swagger-api/swagger-codegen/tree/v2.2.1)
|
[2.2.1](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.1) | 2016-08-07 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.1](https://github.com/swagger-api/swagger-codegen/tree/v2.2.1)
|
||||||
[2.1.6](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.1.6) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6)
|
[2.1.6](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.1.6) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6)
|
||||||
|
@ -9,3 +9,4 @@
|
|||||||
./bin/spring-mvc-petstore-server.sh
|
./bin/spring-mvc-petstore-server.sh
|
||||||
./bin/springboot-petstore-server-beanvalidation.sh
|
./bin/springboot-petstore-server-beanvalidation.sh
|
||||||
./bin/springboot-petstore-server-implicitHeaders.sh
|
./bin/springboot-petstore-server-implicitHeaders.sh
|
||||||
|
./bin/springboot-petstore-server-useOptional.sh
|
||||||
|
4
bin/springboot-petstore-server-useOptional.json
Normal file
4
bin/springboot-petstore-server-useOptional.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"artifactId": "spring-boot-useoptional",
|
||||||
|
"useOptional": true
|
||||||
|
}
|
34
bin/springboot-petstore-server-useOptional.sh
Executable file
34
bin/springboot-petstore-server-useOptional.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/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/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -c bin/springboot-petstore-server-useOptional.json -o samples/server/petstore/springboot-useoptional -DhideGenerationTimestamp=true"
|
||||||
|
|
||||||
|
echo "Removing files and folders under samples/server/petstore/springboot-useoptional/src/main"
|
||||||
|
rm -rf samples/server/petstore/springboot-useoptional/src/main
|
||||||
|
find samples/server/petstore/springboot-useoptional -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -38,3 +38,7 @@ java $JAVA_OPTS -jar $executable $ags
|
|||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-rxswift.json -o samples/client/petstore/swift3/rxswift"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-rxswift.json -o samples/client/petstore/swift3/rxswift"
|
||||||
echo "#### Petstore Swift API client (rxswift) ####"
|
echo "#### Petstore Swift API client (rxswift) ####"
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-unwraprequired.json -o samples/client/petstore/swift3/unwraprequired"
|
||||||
|
echo "#### Petstore Swift API client (unwraprequired) ####"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
7
bin/swift3-petstore-unwraprequired.json
Normal file
7
bin/swift3-petstore-unwraprequired.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"podSummary": "PetstoreClient",
|
||||||
|
"podHomepage": "https://github.com/swagger-api/swagger-codegen",
|
||||||
|
"podAuthors": "",
|
||||||
|
"projectName": "PetstoreClient",
|
||||||
|
"unwrapRequired": true
|
||||||
|
}
|
31
bin/swift3-petstore-unwraprequired.sh
Executable file
31
bin/swift3-petstore-unwraprequired.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/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-unwraprequired.json -o samples/client/petstore/swift3/unwraprequired"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
12
circle.yml
12
circle.yml
@ -32,14 +32,18 @@ dependencies:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
# test with jdk8
|
## test with jdk8
|
||||||
- java -version
|
- java -version
|
||||||
- mvn -q clean verify -Psamples
|
- mvn -q clean verify -Psamples
|
||||||
# test with jdk7
|
# skip the rest if previous mvn task fails
|
||||||
|
- if [ $? -ne 0 ]; then exit 1; fi
|
||||||
|
## test with jdk7
|
||||||
- sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
- sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||||
- java -version
|
- java -version
|
||||||
- mvn -q clean verify -Psamples
|
- mvn -q clean verify -Psamples
|
||||||
# docker: build generator image and push to Docker Hub
|
# skip the rest if previous mvn task fails
|
||||||
|
- if [ $? -ne 0 ]; then exit 1; fi
|
||||||
|
## docker: build generator image and push to Docker Hub
|
||||||
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
|
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
|
||||||
# docker: build cli image and push to Docker Hub
|
## docker: build cli image and push to Docker Hub
|
||||||
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi
|
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$CIRCLE_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$CIRCLE_TAG; fi && if [ ! -z "$CIRCLE_TAG" ] || [ "$CIRCLE_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi
|
||||||
|
@ -607,7 +607,7 @@ public class DefaultCodegen {
|
|||||||
* @return properly-escaped pattern
|
* @return properly-escaped pattern
|
||||||
*/
|
*/
|
||||||
public String toRegularExpression(String pattern) {
|
public String toRegularExpression(String pattern) {
|
||||||
return escapeText(addRegularExpressionDelimiter(pattern));
|
return addRegularExpressionDelimiter(escapeText(pattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3572,9 +3572,14 @@ public class DefaultCodegen {
|
|||||||
* @return the pattern with delimiter
|
* @return the pattern with delimiter
|
||||||
*/
|
*/
|
||||||
public String addRegularExpressionDelimiter(String pattern) {
|
public String addRegularExpressionDelimiter(String pattern) {
|
||||||
if (pattern != null && !pattern.matches("^/.*")) {
|
if (StringUtils.isEmpty(pattern)) {
|
||||||
return "/" + pattern + "/";
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pattern.matches("^/.*")) {
|
||||||
|
return "/" + pattern.replaceAll("/", "\\\\/") + "/";
|
||||||
|
}
|
||||||
|
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,10 +312,10 @@ public class CppRestClientCodegen extends DefaultCodegen implements CodegenConfi
|
|||||||
return "0.0";
|
return "0.0";
|
||||||
} else if (p instanceof FloatProperty) {
|
} else if (p instanceof FloatProperty) {
|
||||||
return "0.0f";
|
return "0.0f";
|
||||||
} else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) {
|
|
||||||
return "0";
|
|
||||||
} else if (p instanceof LongProperty) {
|
} else if (p instanceof LongProperty) {
|
||||||
return "0L";
|
return "0L";
|
||||||
|
} else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) {
|
||||||
|
return "0";
|
||||||
} else if (p instanceof DecimalProperty) {
|
} else if (p instanceof DecimalProperty) {
|
||||||
return "0.0";
|
return "0.0";
|
||||||
} else if (p instanceof MapProperty) {
|
} else if (p instanceof MapProperty) {
|
||||||
|
@ -286,10 +286,10 @@ public class PistacheServerCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
return "0.0";
|
return "0.0";
|
||||||
} else if (p instanceof FloatProperty) {
|
} else if (p instanceof FloatProperty) {
|
||||||
return "0.0f";
|
return "0.0f";
|
||||||
} else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) {
|
|
||||||
return "0";
|
|
||||||
} else if (p instanceof LongProperty) {
|
} else if (p instanceof LongProperty) {
|
||||||
return "0L";
|
return "0L";
|
||||||
|
} else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) {
|
||||||
|
return "0";
|
||||||
} else if (p instanceof DecimalProperty) {
|
} else if (p instanceof DecimalProperty) {
|
||||||
return "0.0";
|
return "0.0";
|
||||||
} else if (p instanceof MapProperty) {
|
} else if (p instanceof MapProperty) {
|
||||||
|
@ -318,10 +318,10 @@ public class RestbedCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return "0.0";
|
return "0.0";
|
||||||
} else if (p instanceof FloatProperty) {
|
} else if (p instanceof FloatProperty) {
|
||||||
return "0.0f";
|
return "0.0f";
|
||||||
} else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) {
|
|
||||||
return "0";
|
|
||||||
} else if (p instanceof LongProperty) {
|
} else if (p instanceof LongProperty) {
|
||||||
return "0L";
|
return "0L";
|
||||||
|
} else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) {
|
||||||
|
return "0";
|
||||||
} else if (p instanceof DecimalProperty) {
|
} else if (p instanceof DecimalProperty) {
|
||||||
return "0.0";
|
return "0.0";
|
||||||
} else if (p instanceof MapProperty) {
|
} else if (p instanceof MapProperty) {
|
||||||
|
@ -4,6 +4,7 @@ import com.samskivert.mustache.Mustache;
|
|||||||
import com.samskivert.mustache.Template;
|
import com.samskivert.mustache.Template;
|
||||||
import io.swagger.codegen.*;
|
import io.swagger.codegen.*;
|
||||||
import io.swagger.codegen.languages.features.BeanValidationFeatures;
|
import io.swagger.codegen.languages.features.BeanValidationFeatures;
|
||||||
|
import io.swagger.codegen.languages.features.OptionalFeatures;
|
||||||
import io.swagger.models.Operation;
|
import io.swagger.models.Operation;
|
||||||
import io.swagger.models.Path;
|
import io.swagger.models.Path;
|
||||||
import io.swagger.models.Swagger;
|
import io.swagger.models.Swagger;
|
||||||
@ -15,7 +16,8 @@ import java.util.*;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
|
||||||
public class SpringCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
|
public class SpringCodegen extends AbstractJavaCodegen
|
||||||
|
implements BeanValidationFeatures, OptionalFeatures {
|
||||||
public static final String DEFAULT_LIBRARY = "spring-boot";
|
public static final String DEFAULT_LIBRARY = "spring-boot";
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
public static final String CONFIG_PACKAGE = "configPackage";
|
public static final String CONFIG_PACKAGE = "configPackage";
|
||||||
@ -45,6 +47,7 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
protected boolean useBeanValidation = true;
|
protected boolean useBeanValidation = true;
|
||||||
protected boolean implicitHeaders = false;
|
protected boolean implicitHeaders = false;
|
||||||
protected boolean swaggerDocketConfig = false;
|
protected boolean swaggerDocketConfig = false;
|
||||||
|
protected boolean useOptional = false;
|
||||||
|
|
||||||
public SpringCodegen() {
|
public SpringCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -75,6 +78,8 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
||||||
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers."));
|
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers."));
|
||||||
cliOptions.add(CliOption.newBoolean(SWAGGER_DOCKET_CONFIG, "Generate Spring Swagger Docket configuration class."));
|
cliOptions.add(CliOption.newBoolean(SWAGGER_DOCKET_CONFIG, "Generate Spring Swagger Docket configuration class."));
|
||||||
|
cliOptions.add(CliOption.newBoolean(USE_OPTIONAL,
|
||||||
|
"Use Optional container for optional parameters"));
|
||||||
|
|
||||||
supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
|
supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
|
||||||
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
||||||
@ -170,11 +175,14 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
|
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(USE_OPTIONAL)) {
|
||||||
|
this.setUseOptional(convertPropertyToBoolean(USE_OPTIONAL));
|
||||||
|
}
|
||||||
|
|
||||||
if (useBeanValidation) {
|
if (useBeanValidation) {
|
||||||
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(IMPLICIT_HEADERS)) {
|
if (additionalProperties.containsKey(IMPLICIT_HEADERS)) {
|
||||||
this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString()));
|
this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString()));
|
||||||
}
|
}
|
||||||
@ -186,6 +194,10 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
typeMapping.put("file", "Resource");
|
typeMapping.put("file", "Resource");
|
||||||
importMapping.put("Resource", "org.springframework.core.io.Resource");
|
importMapping.put("Resource", "org.springframework.core.io.Resource");
|
||||||
|
|
||||||
|
if (useOptional) {
|
||||||
|
writePropertyBack(USE_OPTIONAL, useOptional);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.interfaceOnly && this.delegatePattern) {
|
if (this.interfaceOnly && this.delegatePattern) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("Can not generate code with `%s` and `%s` both true.", DELEGATE_PATTERN, INTERFACE_ONLY));
|
String.format("Can not generate code with `%s` and `%s` both true.", DELEGATE_PATTERN, INTERFACE_ONLY));
|
||||||
@ -649,4 +661,8 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
this.useBeanValidation = useBeanValidation;
|
this.useBeanValidation = useBeanValidation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUseOptional(boolean useOptional) {
|
||||||
|
this.useOptional = useOptional;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CodegenModel;
|
||||||
|
import io.swagger.codegen.CodegenParameter;
|
||||||
|
import io.swagger.models.ModelImpl;
|
||||||
|
import io.swagger.models.properties.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -9,7 +13,6 @@ import java.util.Date;
|
|||||||
|
|
||||||
import io.swagger.codegen.CliOption;
|
import io.swagger.codegen.CliOption;
|
||||||
import io.swagger.codegen.SupportingFile;
|
import io.swagger.codegen.SupportingFile;
|
||||||
import io.swagger.models.properties.BooleanProperty;
|
|
||||||
|
|
||||||
public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodegen {
|
public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
|
||||||
@ -19,6 +22,7 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg
|
|||||||
public static final String NPM_VERSION = "npmVersion";
|
public static final String NPM_VERSION = "npmVersion";
|
||||||
public static final String NPM_REPOSITORY = "npmRepository";
|
public static final String NPM_REPOSITORY = "npmRepository";
|
||||||
public static final String SNAPSHOT = "snapshot";
|
public static final String SNAPSHOT = "snapshot";
|
||||||
|
public static final String JQUERY_ALREADY_IMPORTED = "jqueryAlreadyImported";
|
||||||
|
|
||||||
protected String npmName = null;
|
protected String npmName = null;
|
||||||
protected String npmVersion = "1.0.0";
|
protected String npmVersion = "1.0.0";
|
||||||
@ -26,6 +30,13 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg
|
|||||||
|
|
||||||
public TypeScriptJqueryClientCodegen() {
|
public TypeScriptJqueryClientCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
modelTemplateFiles.put("model.mustache", ".ts");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".ts");
|
||||||
|
typeMapping.put("Date", "Date");
|
||||||
|
apiPackage = "api";
|
||||||
|
modelPackage = "model";
|
||||||
|
|
||||||
outputFolder = "generated-code/typescript-jquery";
|
outputFolder = "generated-code/typescript-jquery";
|
||||||
embeddedTemplateDir = templateDir = "typescript-jquery";
|
embeddedTemplateDir = templateDir = "typescript-jquery";
|
||||||
|
|
||||||
@ -33,23 +44,75 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg
|
|||||||
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
||||||
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||||
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||||
|
this.cliOptions.add(new CliOption(JQUERY_ALREADY_IMPORTED, "When using this in legacy app using mix of typescript and javascript, this will only declare jquery and not import it", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts"));
|
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
|
supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));
|
||||||
|
supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));
|
||||||
|
supportingFiles.add(new SupportingFile("configuration.mustache", getIndexDirectory(), "configuration.ts"));
|
||||||
|
supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts"));
|
||||||
|
supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts"));
|
||||||
|
|
||||||
LOGGER.warn("check additionals: " + additionalProperties.get(NPM_NAME));
|
LOGGER.warn("check additionals: " + additionalProperties.get(NPM_NAME));
|
||||||
if(additionalProperties.containsKey(NPM_NAME)) {
|
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||||
addNpmPackageGeneration();
|
addNpmPackageGeneration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getIndexDirectory() {
|
||||||
|
String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.')));
|
||||||
|
return indexPackage.replace('.', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSwaggerType(Property p) {
|
||||||
|
String swaggerType = super.getSwaggerType(p);
|
||||||
|
if (isLanguagePrimitive(swaggerType) || isLanguageGenericType(swaggerType)) {
|
||||||
|
return swaggerType;
|
||||||
|
}
|
||||||
|
return addModelPrefix(swaggerType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String addModelPrefix(String swaggerType) {
|
||||||
|
String type = null;
|
||||||
|
if (typeMapping.containsKey(swaggerType)) {
|
||||||
|
type = typeMapping.get(swaggerType);
|
||||||
|
} else {
|
||||||
|
type = swaggerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLanguagePrimitive(type) && !isLanguageGenericType(type)) {
|
||||||
|
type = "models." + swaggerType;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLanguagePrimitive(String type) {
|
||||||
|
return languageSpecificPrimitives.contains(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLanguageGenericType(String type) {
|
||||||
|
for (String genericType : languageGenericTypes) {
|
||||||
|
if (type.startsWith(genericType + "<")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postProcessParameter(CodegenParameter parameter) {
|
||||||
|
super.postProcessParameter(parameter);
|
||||||
|
parameter.dataType = addModelPrefix(parameter.dataType);
|
||||||
|
}
|
||||||
|
|
||||||
private void addNpmPackageGeneration() {
|
private void addNpmPackageGeneration() {
|
||||||
if(additionalProperties.containsKey(NPM_NAME)) {
|
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||||
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
|
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +140,12 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg
|
|||||||
return indexPackage.replace('.', File.separatorChar);
|
return indexPackage.replace('.', File.separatorChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, ModelImpl swaggerModel) {
|
||||||
|
codegenModel.additionalPropertiesType = getSwaggerType(swaggerModel.getAdditionalProperties());
|
||||||
|
addImport(codegenModel, codegenModel.additionalPropertiesType);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "typescript-jquery";
|
return "typescript-jquery";
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package io.swagger.codegen.languages.features;
|
||||||
|
|
||||||
|
public interface OptionalFeatures {
|
||||||
|
|
||||||
|
// Language supports generating Optional Types
|
||||||
|
String USE_OPTIONAL = "useOptional";
|
||||||
|
|
||||||
|
void setUseOptional(boolean useOptional);
|
||||||
|
|
||||||
|
}
|
@ -241,7 +241,7 @@
|
|||||||
<spring-version>4.3.9.RELEASE</spring-version>
|
<spring-version>4.3.9.RELEASE</spring-version>
|
||||||
{{/generateSpringApplication}}
|
{{/generateSpringApplication}}
|
||||||
{{#generateSpringBootApplication}}
|
{{#generateSpringBootApplication}}
|
||||||
<spring.boot-version>1.4.7.RELEASE</spring.boot-version>
|
<spring.boot-version>1.5.4.RELEASE</spring.boot-version>
|
||||||
{{/generateSpringBootApplication}}
|
{{/generateSpringBootApplication}}
|
||||||
<cxf-version>3.1.11</cxf-version>
|
<cxf-version>3.1.11</cxf-version>
|
||||||
<jackson-jaxrs-version>2.8.9</jackson-jaxrs-version>
|
<jackson-jaxrs-version>2.8.9</jackson-jaxrs-version>
|
||||||
|
@ -26,6 +26,9 @@ import java.io.IOException;
|
|||||||
{{/useSpringCloudClient}}
|
{{/useSpringCloudClient}}
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
{{#useOptional}}
|
||||||
|
import java.util.Optional;
|
||||||
|
{{/useOptional}}
|
||||||
{{#async}}
|
{{#async}}
|
||||||
import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
|
import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
|
||||||
{{/async}}
|
{{/async}}
|
||||||
|
@ -19,6 +19,9 @@ import org.springframework.web.bind.annotation.RequestPart;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
{{#useOptional}}
|
||||||
|
import java.util.Optional;
|
||||||
|
{{/useOptional}}
|
||||||
{{#async}}
|
{{#async}}
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
{{/async}}
|
{{/async}}
|
||||||
|
@ -1 +1 @@
|
|||||||
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}}
|
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}}
|
@ -9,12 +9,12 @@
|
|||||||
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<springfox-version>2.6.1</springfox-version>
|
<springfox-version>2.7.0</springfox-version>
|
||||||
</properties>
|
</properties>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.4.7.RELEASE</version>
|
<version>1.5.4.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.4.7.RELEASE</version>
|
<version>1.5.4.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-parent</artifactId>
|
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||||
<version>Camden.SR1</version>
|
<version>Dalston.SR1</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -159,7 +159,7 @@
|
|||||||
<slf4j-version>1.7.21</slf4j-version>
|
<slf4j-version>1.7.21</slf4j-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
<servlet-api-version>2.5</servlet-api-version>
|
<servlet-api-version>2.5</servlet-api-version>
|
||||||
<springfox-version>2.6.0</springfox-version>
|
<springfox-version>2.7.0</springfox-version>
|
||||||
<jackson-version>2.8.9</jackson-version>
|
<jackson-version>2.8.9</jackson-version>
|
||||||
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
|
||||||
<spring-version>4.3.9.RELEASE</spring-version>
|
<spring-version>4.3.9.RELEASE</spring-version>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{{#useOptional}}{{#required}}{{{dataType}}}{{/required}}{{^required}}Optional<{{{dataType}}}>{{/required}}{{/useOptional}}{{^useOptional}}{{{dataType}}}{{/useOptional}}
|
@ -1 +1 @@
|
|||||||
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
|
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}}
|
@ -1 +1 @@
|
|||||||
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
|
@ -26,9 +26,9 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}"
|
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}"
|
||||||
|
|
||||||
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
||||||
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
||||||
|
|
||||||
s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
|
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
||||||
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
||||||
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
|
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
|
||||||
s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
|
s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
|
||||||
|
@ -50,7 +50,7 @@ static gpointer __{{classname}}threadFunc(gpointer data)
|
|||||||
|
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData,
|
static bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, void* userData,
|
||||||
void(* voidHandler)())
|
void(* voidHandler)())
|
||||||
{
|
{
|
||||||
{{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<string,string>{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* )
|
{{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<string,string>{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* )
|
||||||
@ -58,9 +58,6 @@ bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, vo
|
|||||||
{{^returnType}}void(* handler)(Error, void* ) = reinterpret_cast<void(*)(Error, void* )> (voidHandler);{{/returnType}}
|
{{^returnType}}void(* handler)(Error, void* ) = reinterpret_cast<void(*)(Error, void* )> (voidHandler);{{/returnType}}
|
||||||
JsonNode* pJson;
|
JsonNode* pJson;
|
||||||
char * data = p_chunk.memory;
|
char * data = p_chunk.memory;
|
||||||
{{#returnType}}
|
|
||||||
printf("%s\n", data);
|
|
||||||
{{/returnType}}
|
|
||||||
|
|
||||||
{{#returnType}}{{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<string,string>{{/isMapContainer}} out;{{/returnContainer}}
|
{{#returnType}}{{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<string,string>{{/isMapContainer}} out;{{/returnContainer}}
|
||||||
{{^returnContainer}}{{returnType}} out;{{/returnContainer}}{{/returnType}}
|
{{^returnContainer}}{{returnType}} out;{{/returnContainer}}{{/returnType}}
|
||||||
@ -137,7 +134,7 @@ bool {{nickname}}Processor(MemoryStruct_s p_chunk, long code, char* errormsg, vo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool {{nickname}}Helper(char * accessToken,
|
static bool {{nickname}}Helper(char * accessToken,
|
||||||
{{#allParams}}{{#isContainer}}{{{dataType}}}<{{baseType}}> {{paramName}}{{/isContainer}}{{^isContainer}}{{{dataType}}} {{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}
|
{{#allParams}}{{#isContainer}}{{{dataType}}}<{{baseType}}> {{paramName}}{{/isContainer}}{{^isContainer}}{{{dataType}}} {{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}
|
||||||
{{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<string,string>{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* ){{/returnType}}
|
{{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<string,string>{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* ){{/returnType}}
|
||||||
{{^returnType}}void(* handler)(Error, void* ) {{/returnType}}, void* userData, bool isAsync)
|
{{^returnType}}void(* handler)(Error, void* ) {{/returnType}}, void* userData, bool isAsync)
|
||||||
@ -159,8 +156,11 @@ bool {{nickname}}Helper(char * accessToken,
|
|||||||
headerList = curl_slist_append(headerList, itemAt);
|
headerList = curl_slist_append(headerList, itemAt);
|
||||||
}
|
}
|
||||||
{{/collectionFormat}}{{^collectionFormat}}
|
{{/collectionFormat}}{{^collectionFormat}}
|
||||||
//TODO - should use value of paramname instead. Also check for empty not-required headers
|
{
|
||||||
headerList = curl_slist_append(headerList, "{{baseName}}: {{paramName}}");
|
string headerString("{{baseName}}: ");
|
||||||
|
headerString.append(stringify(&{{paramName}}, "{{dataType}}"));
|
||||||
|
headerList = curl_slist_append(headerList, headerString.c_str());
|
||||||
|
}
|
||||||
{{/collectionFormat}}
|
{{/collectionFormat}}
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
|
|
||||||
@ -204,7 +204,8 @@ bool {{nickname}}Helper(char * accessToken,
|
|||||||
string mBody = "";
|
string mBody = "";
|
||||||
JsonNode* node;
|
JsonNode* node;
|
||||||
JsonArray* json_array;
|
JsonArray* json_array;
|
||||||
{{#bodyParams}}
|
{{#allParams}}
|
||||||
|
{{#isBodyParam}}
|
||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
//TODO: Map Container
|
//TODO: Map Container
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
@ -256,17 +257,18 @@ bool {{nickname}}Helper(char * accessToken,
|
|||||||
if (isprimitive("{{baseType}}")) {
|
if (isprimitive("{{baseType}}")) {
|
||||||
node = converttoJson(&{{paramName}}, "{{baseType}}", "");
|
node = converttoJson(&{{paramName}}, "{{baseType}}", "");
|
||||||
}
|
}
|
||||||
{{^isInteger}}{{^isDate}}{{^isLong}}{{^isBoolean}}{{^isFloat}}{{^isString}}{{^isDateTime}}{{^isDouble}}
|
{{^isPrimitiveType}}{{^isInteger}}{{^isDate}}{{^isLong}}{{^isBoolean}}{{^isFloat}}{{^isString}}{{^isDateTime}}{{^isDouble}}
|
||||||
char *jsonStr = {{paramName}}.toJson();
|
char *jsonStr = {{paramName}}.toJson();
|
||||||
node = json_from_string(jsonStr, NULL);
|
node = json_from_string(jsonStr, NULL);
|
||||||
g_free(static_cast<gpointer>(jsonStr));
|
g_free(static_cast<gpointer>(jsonStr));
|
||||||
{{/isDouble}}{{/isDateTime}}{{/isString}}{{/isFloat}}{{/isBoolean}}{{/isLong}}{{/isDate}}{{/isInteger}}
|
{{/isDouble}}{{/isDateTime}}{{/isString}}{{/isFloat}}{{/isBoolean}}{{/isLong}}{{/isDate}}{{/isInteger}}{{/isPrimitiveType}}
|
||||||
|
|
||||||
{{/isContainer}}
|
{{/isContainer}}
|
||||||
char *jsonStr1 = json_to_string(node, false);
|
char *jsonStr1 = json_to_string(node, false);
|
||||||
mBody.append(jsonStr1);
|
mBody.append(jsonStr1);
|
||||||
g_free(static_cast<gpointer>(jsonStr1));
|
g_free(static_cast<gpointer>(jsonStr1));
|
||||||
{{/bodyParams}}
|
{{/isBodyParam}}
|
||||||
|
{{/allParams}}
|
||||||
|
|
||||||
string url("{{{path}}}");
|
string url("{{{path}}}");
|
||||||
int pos;
|
int pos;
|
||||||
|
@ -10,9 +10,18 @@
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
|
|
||||||
|
/** \defgroup Operations API Endpoints
|
||||||
|
* Classes containing all the functions for calling API endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Tizen{
|
namespace Tizen{
|
||||||
namespace {{prefix}} {
|
namespace {{prefix}} {
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
|
/** \addtogroup {{{baseName}}} {{{baseName}}}
|
||||||
|
* \ingroup Operations
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
class {{classname}} {
|
class {{classname}} {
|
||||||
public:
|
public:
|
||||||
{{classname}}();
|
{{classname}}();
|
||||||
@ -44,6 +53,8 @@ bool {{nickname}}Async(char * accessToken,
|
|||||||
{{#allParams}}{{#isContainer}}{{{dataType}}}<{{baseType}}> {{paramName}}{{/isContainer}}{{^isContainer}}{{{dataType}}} {{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}
|
{{#allParams}}{{#isContainer}}{{{dataType}}}<{{baseType}}> {{paramName}}{{/isContainer}}{{^isContainer}}{{{dataType}}} {{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}
|
||||||
{{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<std::string,std::string>{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* ){{/returnType}}
|
{{#returnType}}void(* handler)({{#returnContainer}}{{#isListContainer}}{{returnType}}<{{returnBaseType}}>{{/isListContainer}}{{#isMapContainer}}{{returnType}}<std::string,std::string>{{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}, Error, void* ){{/returnType}}
|
||||||
{{^returnType}}void(* handler)(Error, void* ) {{/returnType}}, void* userData);
|
{{^returnType}}void(* handler)(Error, void* ) {{/returnType}}, void* userData);
|
||||||
|
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
|
||||||
static std::string getBasePath()
|
static std::string getBasePath()
|
||||||
@ -51,6 +62,7 @@ bool {{nickname}}Async(char * accessToken,
|
|||||||
return "{{{basePath}}}";
|
return "{{{basePath}}}";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/** @}*/
|
||||||
|
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Documentation for {{#swagger}}{{#info}}{{title}} {{version}} Tizen SDK{{/info}}{{/swagger}}
|
# Documentation for {{#swagger}}{{#info}}{{title}} {{version}} Tizen Client SDK{{/info}}{{/swagger}}
|
||||||
|
|
||||||
## How do I get the doc files?
|
## How do I get the doc files?
|
||||||
First generate source code by running `swagger-codegen`
|
First generate source code by running `swagger-codegen`
|
||||||
@ -16,7 +16,7 @@ This is the structure of the doc folder:
|
|||||||
├── Doxyfile \\Doxygen config files
|
├── Doxyfile \\Doxygen config files
|
||||||
├── generateDocumentation.sh \\Script to run to generate documentation
|
├── generateDocumentation.sh \\Script to run to generate documentation
|
||||||
├── README.md \\This file
|
├── README.md \\This file
|
||||||
├── SDK \\Documentation for all classes in Tizen Client SDK for Artik Cloud. See ./html/index.html
|
├── SDK \\Documentation for all classes in {{#swagger}}{{#info}}{{title}} Tizen Client SDK{{/info}}{{/swagger}}. See ./html/index.html
|
||||||
│ └── html
|
│ └── html
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -36,13 +36,19 @@ Doxygen is the de facto standard tool for generating/extracting documentation fr
|
|||||||
Check out [Doxygen](https://www.doxygen.org/) for additional information about the Doxygen project.
|
Check out [Doxygen](https://www.doxygen.org/) for additional information about the Doxygen project.
|
||||||
|
|
||||||
## I Don't want to run Doxygen. What are the API files for accessing the REST endpoints?
|
## I Don't want to run Doxygen. What are the API files for accessing the REST endpoints?
|
||||||
|
All URIs are relative to {{{scheme}}}://{{{host}}}{{{basePath}}}
|
||||||
{{#apiInfo}}{{#apis}}{{#operations}}
|
{{#apiInfo}}{{#apis}}{{#operations}}
|
||||||
* [{{classname}}](../src/{{classname}}.cpp)
|
### {{classname}}
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
* *{{nickname}}Sync* / *{{nickname}}Async* - {{{summary}}}.
|
*{{nickname}}Sync* | *{{httpMethod}}* {{{path}}} | {{{summary}}}.
|
||||||
{{/operation}}
|
*{{nickname}}ASync* | *{{httpMethod}}* {{{path}}} | {{{summary}}}.
|
||||||
|
{{/operation}}
|
||||||
{{/operations}}{{/apis}}{{/apiInfo}}
|
{{/operations}}{{/apis}}{{/apiInfo}}
|
||||||
|
|
||||||
## What are the Model files for the data structures/objects?
|
## What are the Model files for the data structures/objects?
|
||||||
{{#models}}{{#model}}
|
Class | Description
|
||||||
* [{{classname}}](../src/{{classname}}.cpp) - {{{description}}}{{/model}}{{/models}}
|
------------- | -------------
|
||||||
|
{{#models}}{{#model}} *{{classname}}* | {{{description}}}
|
||||||
|
{{/model}}{{/models}}
|
||||||
|
@ -13,7 +13,7 @@ using namespace Tizen::{{prefix}};
|
|||||||
|
|
||||||
void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_node,gpointer user_data)
|
void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_node,gpointer user_data)
|
||||||
{
|
{
|
||||||
const gchar* member_string;
|
gchar* member_string;
|
||||||
if (!JSON_NODE_HOLDS_VALUE(member_node)) {
|
if (!JSON_NODE_HOLDS_VALUE(member_node)) {
|
||||||
if (JSON_NODE_HOLDS_OBJECT(member_node)) {
|
if (JSON_NODE_HOLDS_OBJECT(member_node)) {
|
||||||
JsonNode* tempnode = json_node_alloc();
|
JsonNode* tempnode = json_node_alloc();
|
||||||
@ -27,10 +27,42 @@ void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_
|
|||||||
json_node_free(tempnode);
|
json_node_free(tempnode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
member_string = json_node_get_string(member_node);
|
member_string = (char*) json_node_get_string(member_node);
|
||||||
|
if (member_string == NULL) {
|
||||||
|
char * valueType = (char*) json_node_type_name(member_node);
|
||||||
|
if(strcmp(valueType,"Boolean") == 0){
|
||||||
|
gboolean member_boolean = json_node_get_boolean(member_node);
|
||||||
|
if (member_boolean == 0) {
|
||||||
|
member_string = new char[std::strlen("false") + 1];
|
||||||
|
strcpy(member_string, "false");
|
||||||
|
} else {
|
||||||
|
member_string = new char[std::strlen("true") + 1];
|
||||||
|
strcpy(member_string, "true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strcmp(valueType,"Integer") == 0){
|
||||||
|
long long int member_int = json_node_get_int(member_node);
|
||||||
|
ostringstream ss;
|
||||||
|
ss << member_int;
|
||||||
|
string temp_member = ss.str();
|
||||||
|
const char * temp_char = temp_member.c_str();
|
||||||
|
member_string = new char[strlen(temp_char) + 1];
|
||||||
|
strcpy(member_string, temp_char);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
double member_double = json_node_get_double(member_node);
|
||||||
|
ostringstream ss;
|
||||||
|
ss << member_double;
|
||||||
|
string temp_member = ss.str();
|
||||||
|
const char * temp_char = temp_member.c_str();
|
||||||
|
member_string = new char[strlen(temp_char) + 1];
|
||||||
|
strcpy(member_string, temp_char);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
map<string,string>* new_map = static_cast<map<string,string>*>(user_data);
|
map<string,string>* new_map = static_cast<map<string,string>*>(user_data);
|
||||||
(*new_map)[string(member_name)] = string(member_string);
|
(*new_map)[string(member_name)] = string(member_string);
|
||||||
|
delete[] member_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * json_to_string(JsonNode *node, gboolean pretty)
|
char * json_to_string(JsonNode *node, gboolean pretty)
|
||||||
@ -64,7 +96,11 @@ json_from_string(const char *str, GError **mygerror)
|
|||||||
if (!json_parser_load_from_data(parser, str, -1, mygerror))
|
if (!json_parser_load_from_data(parser, str, -1, mygerror))
|
||||||
{
|
{
|
||||||
g_object_unref(parser);
|
g_object_unref(parser);
|
||||||
|
if(str == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
retval = json_node_alloc();
|
||||||
|
retval = json_node_init_string (retval, str);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = json_node_copy(json_parser_get_root(parser));
|
retval = json_node_copy(json_parser_get_root(parser));
|
||||||
|
@ -14,11 +14,18 @@
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
|
/** \defgroup Models Data Structures for API
|
||||||
|
* Classes containing all the Data Structures needed for calling/returned by API endpoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Tizen {
|
namespace Tizen {
|
||||||
namespace {{prefix}} {
|
namespace {{prefix}} {
|
||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
|
|
||||||
/*! \brief {{{description}}}
|
/*! \brief {{{description}}}
|
||||||
|
*
|
||||||
|
* \ingroup Models
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,18 +2,18 @@ export interface ConfigurationParameters {
|
|||||||
apiKeys?: {[ key: string ]: string};
|
apiKeys?: {[ key: string ]: string};
|
||||||
username?: string;
|
username?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
accessToken?: string;
|
accessToken?: string | (() => string);
|
||||||
basePath?: string;
|
basePath?: string;
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Configuration {
|
export class Configuration {
|
||||||
apiKeys: {[ key: string ]: string};
|
apiKeys?: {[ key: string ]: string};
|
||||||
username: string;
|
username?: string;
|
||||||
password: string;
|
password?: string;
|
||||||
accessToken: string | (() => string);
|
accessToken?: string | (() => string);
|
||||||
basePath: string;
|
basePath?: string;
|
||||||
withCredentials: boolean;
|
withCredentials?: boolean;
|
||||||
|
|
||||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||||
this.apiKeys = configurationParameters.apiKeys;
|
this.apiKeys = configurationParameters.apiKeys;
|
||||||
|
@ -1,175 +1,41 @@
|
|||||||
|
{{>licenseInfo}}
|
||||||
|
|
||||||
|
{{#jqueryAlreadyImported}}
|
||||||
|
declare var $ : any;
|
||||||
|
{{/jqueryAlreadyImported}}
|
||||||
|
{{^jqueryAlreadyImported}}
|
||||||
import * as $ from 'jquery';
|
import * as $ from 'jquery';
|
||||||
|
{{/jqueryAlreadyImported}}
|
||||||
|
import * as models from '../model/models';
|
||||||
|
import { COLLECTION_FORMATS } from '../variables';
|
||||||
|
import { Configuration } from '../configuration';
|
||||||
|
|
||||||
let defaultBasePath = '{{{basePath}}}';
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
// ===============================================
|
|
||||||
// This file is autogenerated - Please do not edit
|
|
||||||
// ===============================================
|
|
||||||
|
|
||||||
/* tslint:disable:no-unused-variable */
|
|
||||||
|
|
||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
{{#description}}
|
|
||||||
/**
|
|
||||||
* {{{description}}}
|
|
||||||
*/
|
|
||||||
{{/description}}
|
|
||||||
export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
|
||||||
{{#vars}}
|
|
||||||
{{#description}}
|
|
||||||
/**
|
|
||||||
* {{{description}}}
|
|
||||||
*/
|
|
||||||
{{/description}}
|
|
||||||
'{{name}}': {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
|
||||||
{{/vars}}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#hasEnums}}
|
|
||||||
export namespace {{classname}} {
|
|
||||||
{{#vars}}
|
|
||||||
{{#isEnum}}
|
|
||||||
export enum {{enumName}} {
|
|
||||||
{{#allowableValues}}
|
|
||||||
{{#enumVars}}
|
|
||||||
{{name}} = <any> {{{value}}}{{^-last}},{{/-last}}
|
|
||||||
{{/enumVars}}
|
|
||||||
{{/allowableValues}}
|
|
||||||
}
|
|
||||||
{{/isEnum}}
|
|
||||||
{{/vars}}
|
|
||||||
}
|
|
||||||
{{/hasEnums}}
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
||||||
|
|
||||||
export interface Authentication {
|
|
||||||
/**
|
|
||||||
* Apply authentication settings to header and query params.
|
|
||||||
*/
|
|
||||||
applyToRequest(requestOptions: JQueryAjaxSettings): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class HttpBasicAuth implements Authentication {
|
|
||||||
public username: string;
|
|
||||||
public password: string;
|
|
||||||
applyToRequest(requestOptions: any): void {
|
|
||||||
requestOptions.username = this.username;
|
|
||||||
requestOptions.password = this.password;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ApiKeyAuth implements Authentication {
|
|
||||||
public apiKey: string;
|
|
||||||
|
|
||||||
constructor(private location: string, private paramName: string) {
|
|
||||||
}
|
|
||||||
|
|
||||||
applyToRequest(requestOptions: JQueryAjaxSettings): void {
|
|
||||||
requestOptions.headers[this.paramName] = this.apiKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class OAuth implements Authentication {
|
|
||||||
public accessToken: string;
|
|
||||||
|
|
||||||
applyToRequest(requestOptions: JQueryAjaxSettings): void {
|
|
||||||
requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class VoidAuth implements Authentication {
|
|
||||||
public username: string;
|
|
||||||
public password: string;
|
|
||||||
applyToRequest(requestOptions: JQueryAjaxSettings): void {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#apiInfo}}
|
|
||||||
{{#apis}}
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
|
|
||||||
{{#description}}
|
{{#description}}
|
||||||
/**
|
/**
|
||||||
* {{&description}}
|
* {{&description}}
|
||||||
*/
|
*/
|
||||||
{{/description}}
|
{{/description}}
|
||||||
export enum {{classname}}ApiKeys {
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isApiKey}}
|
|
||||||
{{name}},
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{/authMethods}}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class {{classname}} {
|
export class {{classname}} {
|
||||||
protected basePath = defaultBasePath;
|
protected basePath = '{{{basePath}}}';
|
||||||
protected defaultHeaders : any = {};
|
public defaultHeaders: Array<string> = [];
|
||||||
|
public configuration: Configuration = new Configuration();
|
||||||
|
|
||||||
protected authentications = {
|
constructor(basePath?: string, configuration?: Configuration) {
|
||||||
'default': <Authentication>new VoidAuth(),
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
'{{name}}': new HttpBasicAuth(),
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
|
||||||
'{{name}}': new ApiKeyAuth({{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{^isKeyInHeader}}'query'{{/isKeyInHeader}}, '{{keyParamName}}'),
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
'{{name}}': new OAuth(),
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(basePath?: string);
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
constructor(username: string, password: string, basePath?: string);
|
|
||||||
{{/isBasic}}
|
|
||||||
{{/authMethods}}
|
|
||||||
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
|
|
||||||
if (password) {
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
this.username = basePathOrUsername;
|
|
||||||
this.password = password
|
|
||||||
{{/isBasic}}
|
|
||||||
{{/authMethods}}
|
|
||||||
if (basePath) {
|
if (basePath) {
|
||||||
this.basePath = basePath;
|
this.basePath = basePath;
|
||||||
}
|
}
|
||||||
} else {
|
if (configuration) {
|
||||||
if (basePathOrUsername) {
|
this.configuration = configuration;
|
||||||
this.basePath = basePathOrUsername
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setApiKey(key: {{classname}}ApiKeys, value: string) {
|
|
||||||
this.authentications[{{classname}}ApiKeys[key]].apiKey = value;
|
|
||||||
}
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
|
|
||||||
set username(username: string) {
|
|
||||||
this.authentications.{{name}}.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
set password(password: string) {
|
|
||||||
this.authentications.{{name}}.password = password;
|
|
||||||
}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
|
|
||||||
set accessToken(token: string) {
|
|
||||||
this.authentications.{{name}}.accessToken = token;
|
|
||||||
}
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
|
private extendObj<T1, T2 extends T1>(objA: T2, objB: T2): T1|T2 {
|
||||||
for(let key in objB){
|
for (let key in objB) {
|
||||||
if(objB.hasOwnProperty(key)){
|
if (objB.hasOwnProperty(key)) {
|
||||||
objA[key] = objB[key];
|
objA[key] = objB[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,59 +48,149 @@ export class {{classname}} {
|
|||||||
* {{notes}}
|
* {{notes}}
|
||||||
{{#allParams}}* @param {{paramName}} {{description}}
|
{{#allParams}}* @param {{paramName}} {{description}}
|
||||||
{{/allParams}}*/
|
{{/allParams}}*/
|
||||||
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : JQueryPromise<{ response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
|
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): JQueryPromise<{ response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
|
||||||
let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}
|
let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
|
||||||
.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
|
|
||||||
let queryParameters: any = {};
|
|
||||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
|
||||||
|
|
||||||
{{#allParams}}{{#required}}
|
let queryParameters: any = {};
|
||||||
|
let headerParams: any = {};
|
||||||
|
{{#hasFormParams}}
|
||||||
|
let formParams = new FormData();
|
||||||
|
let reqHasFile = false;
|
||||||
|
|
||||||
|
{{/hasFormParams}}
|
||||||
|
{{#allParams}}
|
||||||
|
{{#required}}
|
||||||
// verify required parameter '{{paramName}}' is not null or undefined
|
// verify required parameter '{{paramName}}' is not null or undefined
|
||||||
if ({{paramName}} === null || {{paramName}} === undefined) {
|
if ({{paramName}} === null || {{paramName}} === undefined) {
|
||||||
throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
|
throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
|
||||||
}
|
}
|
||||||
{{/required}}{{/allParams}}
|
{{/required}}
|
||||||
{{#queryParams}}
|
|
||||||
if ({{paramName}} !== undefined) {
|
|
||||||
queryParameters['{{baseName}}'] = {{paramName}};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
{{/allParams}}
|
||||||
|
{{#queryParams}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
if ({{paramName}}) {
|
||||||
|
{{#isCollectionFormatMulti}}
|
||||||
|
{{paramName}}.forEach((element: any) => {
|
||||||
|
queryParameters['{{baseName}}'].push(element);
|
||||||
|
});
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
|
{{^isCollectionFormatMulti}}
|
||||||
|
queryParameters['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']);
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
|
}
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{^isListContainer}}
|
||||||
|
if ({{paramName}} !== null && {{paramName}} !== undefined) {
|
||||||
|
{{#isDateTime}}
|
||||||
|
queryParameters['{{baseName}}'] = {{paramName}}.toISOString();
|
||||||
|
{{/isDateTime}}
|
||||||
|
{{^isDateTime}}
|
||||||
|
{{#isDate}}
|
||||||
|
queryParameters['{{baseName}}'] = {{paramName}}.toISOString();
|
||||||
|
{{/isDate}}
|
||||||
|
{{^isDate}}
|
||||||
|
queryParameters['{{baseName}}'] = <string><any>{{paramName}};
|
||||||
|
{{/isDate}}
|
||||||
|
{{/isDateTime}}
|
||||||
|
}
|
||||||
|
{{/isListContainer}}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
|
|
||||||
localVarPath = localVarPath + "?" + $.param(queryParameters);
|
localVarPath = localVarPath + "?" + $.param(queryParameters);
|
||||||
|
|
||||||
{{#headerParams}}
|
|
||||||
headerParams['{{baseName}}'] = {{paramName}};
|
|
||||||
|
|
||||||
{{/headerParams}}
|
|
||||||
|
|
||||||
{{^bodyParam}}
|
|
||||||
let reqHasFile = false;
|
|
||||||
let reqDict = {};
|
|
||||||
let reqFormData = new FormData();
|
|
||||||
{{#formParams}}
|
{{#formParams}}
|
||||||
{{#isFile}}
|
{{#isFile}}
|
||||||
reqHasFile = true;
|
reqHasFile = true;
|
||||||
{{/isFile}}
|
{{/isFile}}
|
||||||
if ({{paramName}} !== undefined) {
|
{{#isListContainer}}
|
||||||
reqFormData.append('{{baseName}}', {{paramName}});
|
if ({{paramName}}) {
|
||||||
reqDict['{{baseName}}'] = {{paramName}};
|
{{#isCollectionFormatMulti}}
|
||||||
|
{{paramName}}.forEach((element: any) => {
|
||||||
|
formParams.append('{{baseName}}', element);
|
||||||
|
});
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
|
{{^isCollectionFormatMulti}}
|
||||||
|
formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
}
|
}
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{^isListContainer}}
|
||||||
|
if ({{paramName}} !== null && {{paramName}} !== undefined) {
|
||||||
|
formParams.append('{{baseName}}', <any>{{paramName}});
|
||||||
|
}
|
||||||
|
{{/isListContainer}}
|
||||||
|
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
{{/bodyParam}}
|
{{#headerParams}}
|
||||||
{{#bodyParam}}
|
{{#isListContainer}}
|
||||||
let reqDict = {{paramName}};
|
if ({{paramName}}) {
|
||||||
let reqFormData = new FormData();
|
headerParams['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']);
|
||||||
reqFormData.append('{{paramName}}', {{paramName}});
|
}
|
||||||
{{#isFile}}
|
{{/isListContainer}}
|
||||||
let reqHasFile = true;
|
{{^isListContainer}}
|
||||||
{{/isFile}}
|
headerParams['{{baseName}}'] = String({{paramName}});
|
||||||
{{^isFile}}
|
{{/isListContainer}}
|
||||||
let reqHasFile = false;
|
|
||||||
{{/isFile}}
|
|
||||||
{{/bodyParam}}
|
|
||||||
|
|
||||||
|
{{/headerParams}}
|
||||||
|
// to determine the Content-Type header
|
||||||
|
let consumes: string[] = [
|
||||||
|
{{#consumes}}
|
||||||
|
'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}
|
||||||
|
{{/consumes}}
|
||||||
|
];
|
||||||
|
|
||||||
|
// to determine the Accept header
|
||||||
|
let produces: string[] = [
|
||||||
|
{{#produces}}
|
||||||
|
'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}
|
||||||
|
{{/produces}}
|
||||||
|
];
|
||||||
|
|
||||||
|
{{#authMethods}}
|
||||||
|
// authentication ({{name}}) required
|
||||||
|
{{#isApiKey}}
|
||||||
|
{{#isKeyInHeader}}
|
||||||
|
if (this.configuration.apiKey) {
|
||||||
|
headerParams['{{keyParamName}}'] = this.configuration.apiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isKeyInHeader}}
|
||||||
|
{{#isKeyInQuery}}
|
||||||
|
if (this.configuration.apiKey) {
|
||||||
|
queryParameters.set('{{keyParamName}}', this.configuration.apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isKeyInQuery}}
|
||||||
|
{{/isApiKey}}
|
||||||
|
{{#isBasic}}
|
||||||
|
// http basic authentication required
|
||||||
|
if (this.configuration.username || this.configuration.password) {
|
||||||
|
headerParams['Authorization'] = 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password);
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isBasic}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken) {
|
||||||
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headerParams['Authorization'] = 'Bearer ' + accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
{{#hasFormParams}}
|
||||||
|
if (!reqHasFile) {
|
||||||
|
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/hasFormParams}}
|
||||||
|
|
||||||
|
{{#bodyParam}}
|
||||||
|
headerParams['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
{{/bodyParam}}
|
||||||
let requestOptions: JQueryAjaxSettings = {
|
let requestOptions: JQueryAjaxSettings = {
|
||||||
url: localVarPath,
|
url: localVarPath,
|
||||||
type: '{{httpMethod}}',
|
type: '{{httpMethod}}',
|
||||||
@ -242,28 +198,29 @@ export class {{classname}} {
|
|||||||
processData: false
|
processData: false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Object.keys(reqDict).length) {
|
{{#bodyParam}}
|
||||||
requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict);
|
requestOptions.data = JSON.stringify({{paramName}});
|
||||||
requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8';
|
{{/bodyParam}}
|
||||||
|
if (headerParams['Content-Type']) {
|
||||||
|
requestOptions.contentType = headerParams['Content-Type'];
|
||||||
}
|
}
|
||||||
|
{{#hasFormParams}}
|
||||||
{{#authMethods}}
|
requestOptions.data = formParams;
|
||||||
this.authentications.{{name}}.applyToRequest(requestOptions);
|
if (reqHasFile) {
|
||||||
|
requestOptions.contentType = false;
|
||||||
{{/authMethods}}
|
}
|
||||||
this.authentications.default.applyToRequest(requestOptions);
|
{{/hasFormParams}}
|
||||||
|
|
||||||
let dfd = $.Deferred();
|
let dfd = $.Deferred();
|
||||||
$.ajax(requestOptions).then(
|
$.ajax(requestOptions).then(
|
||||||
(data: {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}, textStatus: string, jqXHR: JQueryXHR) =>
|
(data: {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}, textStatus: string, jqXHR: JQueryXHR) =>
|
||||||
dfd.resolve({ response: jqXHR, body: data }),
|
dfd.resolve(jqXHR, data),
|
||||||
(xhr: JQueryXHR, textStatus: string, errorThrown: string) =>
|
(xhr: JQueryXHR, textStatus: string, errorThrown: string) =>
|
||||||
dfd.reject({ response: xhr, body: errorThrown })
|
dfd.reject(xhr, errorThrown)
|
||||||
);
|
);
|
||||||
return dfd.promise();
|
return dfd.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
{{/apis}}
|
|
||||||
{{/apiInfo}}
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
{{#apiInfo}}
|
||||||
|
{{#apis}}
|
||||||
|
{{#operations}}
|
||||||
|
export * from './{{ classFilename }}';
|
||||||
|
import { {{ classname }} } from './{{ classFilename }}';
|
||||||
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}];
|
||||||
|
{{/apiInfo}}
|
@ -0,0 +1,6 @@
|
|||||||
|
export class Configuration {
|
||||||
|
apiKey: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
accessToken: string | (() => string);
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
export * from './api/api';
|
||||||
|
export * from './model/models';
|
||||||
|
export * from './variables';
|
||||||
|
export * from './configuration';
|
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* {{{appName}}}
|
||||||
|
* {{{appDescription}}}
|
||||||
|
*
|
||||||
|
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
||||||
|
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
@ -0,0 +1,13 @@
|
|||||||
|
{{>licenseInfo}}
|
||||||
|
import * as models from './models';
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
|
||||||
|
{{#description}}
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
*/
|
||||||
|
{{/description}}
|
||||||
|
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
@ -0,0 +1,12 @@
|
|||||||
|
{{#description}}
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
*/
|
||||||
|
{{/description}}
|
||||||
|
export enum {{classname}} {
|
||||||
|
{{#allowableValues}}
|
||||||
|
{{#enumVars}}
|
||||||
|
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
{{/allowableValues}}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}}{
|
||||||
|
{{#additionalPropertiesType}}
|
||||||
|
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
||||||
|
|
||||||
|
{{/additionalPropertiesType}}
|
||||||
|
{{#vars}}
|
||||||
|
{{#description}}
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
*/
|
||||||
|
{{/description}}
|
||||||
|
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
||||||
|
|
||||||
|
{{/vars}}
|
||||||
|
}{{#hasEnums}}
|
||||||
|
export namespace {{classname}} {
|
||||||
|
{{#vars}}
|
||||||
|
{{#isEnum}}
|
||||||
|
export enum {{enumName}} {
|
||||||
|
{{#allowableValues}}
|
||||||
|
{{#enumVars}}
|
||||||
|
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
{{/allowableValues}}
|
||||||
|
}
|
||||||
|
{{/isEnum}}
|
||||||
|
{{/vars}}
|
||||||
|
}{{/hasEnums}}
|
@ -0,0 +1,5 @@
|
|||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
export * from './{{{ classname }}}';
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
'csv': ',',
|
||||||
|
'tsv': ' ',
|
||||||
|
'ssv': ' ',
|
||||||
|
'pipes': '|'
|
||||||
|
}
|
@ -21,6 +21,7 @@ public class SpringOptionsProvider extends JavaOptionsProvider {
|
|||||||
public static final String USE_BEANVALIDATION = "false";
|
public static final String USE_BEANVALIDATION = "false";
|
||||||
public static final String IMPLICIT_HEADERS = "false";
|
public static final String IMPLICIT_HEADERS = "false";
|
||||||
public static final String SWAGGER_DOCKET_CONFIG = "false";
|
public static final String SWAGGER_DOCKET_CONFIG = "false";
|
||||||
|
public static final String USE_OPTIONAL = "false";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
@ -44,6 +45,7 @@ public class SpringOptionsProvider extends JavaOptionsProvider {
|
|||||||
options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION);
|
options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION);
|
||||||
options.put(SpringCodegen.IMPLICIT_HEADERS, IMPLICIT_HEADERS);
|
options.put(SpringCodegen.IMPLICIT_HEADERS, IMPLICIT_HEADERS);
|
||||||
options.put(SpringCodegen.SWAGGER_DOCKET_CONFIG, SWAGGER_DOCKET_CONFIG);
|
options.put(SpringCodegen.SWAGGER_DOCKET_CONFIG, SWAGGER_DOCKET_CONFIG);
|
||||||
|
options.put(SpringCodegen.USE_OPTIONAL, USE_OPTIONAL);
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import io.swagger.codegen.CodegenConfig;
|
|||||||
import io.swagger.codegen.java.JavaClientOptionsTest;
|
import io.swagger.codegen.java.JavaClientOptionsTest;
|
||||||
import io.swagger.codegen.languages.SpringCodegen;
|
import io.swagger.codegen.languages.SpringCodegen;
|
||||||
import io.swagger.codegen.options.SpringOptionsProvider;
|
import io.swagger.codegen.options.SpringOptionsProvider;
|
||||||
|
|
||||||
import mockit.Expectations;
|
import mockit.Expectations;
|
||||||
import mockit.Tested;
|
import mockit.Tested;
|
||||||
|
|
||||||
@ -77,6 +76,9 @@ public class SpringOptionsTest extends JavaClientOptionsTest {
|
|||||||
times = 1;
|
times = 1;
|
||||||
clientCodegen.setSwaggerDocketConfig(Boolean.valueOf(SpringOptionsProvider.SWAGGER_DOCKET_CONFIG));
|
clientCodegen.setSwaggerDocketConfig(Boolean.valueOf(SpringOptionsProvider.SWAGGER_DOCKET_CONFIG));
|
||||||
times = 1;
|
times = 1;
|
||||||
|
clientCodegen.setUseOptional(
|
||||||
|
Boolean.valueOf(SpringOptionsProvider.USE_OPTIONAL));
|
||||||
|
times = 1;
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -710,6 +710,18 @@
|
|||||||
<module>samples/server/petstore/spring-mvc</module>
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>springboot-useoptional</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>java</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/server/petstore/springboot-useoptional</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>springboot-beanvalidation</id>
|
<id>springboot-beanvalidation</id>
|
||||||
<activation>
|
<activation>
|
||||||
@ -821,6 +833,7 @@
|
|||||||
<module>samples/client/petstore/spring-cloud</module>
|
<module>samples/client/petstore/spring-cloud</module>
|
||||||
<module>samples/server/petstore/springboot</module>
|
<module>samples/server/petstore/springboot</module>
|
||||||
<module>samples/server/petstore/springboot-beanvalidation</module>
|
<module>samples/server/petstore/springboot-beanvalidation</module>
|
||||||
|
<module>samples/server/petstore/springboot-useoptional</module>
|
||||||
<module>samples/server/petstore/jaxrs-cxf</module>
|
<module>samples/server/petstore/jaxrs-cxf</module>
|
||||||
<module>samples/server/petstore/jaxrs-cxf-annotated-base-path</module>
|
<module>samples/server/petstore/jaxrs-cxf-annotated-base-path</module>
|
||||||
<module>samples/server/petstore/jaxrs-cxf-cdi</module>
|
<module>samples/server/petstore/jaxrs-cxf-cdi</module>
|
||||||
|
@ -21,7 +21,7 @@ namespace model {
|
|||||||
|
|
||||||
Category::Category()
|
Category::Category()
|
||||||
{
|
{
|
||||||
m_Id = 0;
|
m_Id = 0L;
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
m_Name = U("");
|
m_Name = U("");
|
||||||
m_NameIsSet = false;
|
m_NameIsSet = false;
|
||||||
|
@ -21,9 +21,9 @@ namespace model {
|
|||||||
|
|
||||||
Order::Order()
|
Order::Order()
|
||||||
{
|
{
|
||||||
m_Id = 0;
|
m_Id = 0L;
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
m_PetId = 0;
|
m_PetId = 0L;
|
||||||
m_PetIdIsSet = false;
|
m_PetIdIsSet = false;
|
||||||
m_Quantity = 0;
|
m_Quantity = 0;
|
||||||
m_QuantityIsSet = false;
|
m_QuantityIsSet = false;
|
||||||
|
@ -21,7 +21,7 @@ namespace model {
|
|||||||
|
|
||||||
Pet::Pet()
|
Pet::Pet()
|
||||||
{
|
{
|
||||||
m_Id = 0;
|
m_Id = 0L;
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
m_CategoryIsSet = false;
|
m_CategoryIsSet = false;
|
||||||
m_Name = U("");
|
m_Name = U("");
|
||||||
|
@ -21,7 +21,7 @@ namespace model {
|
|||||||
|
|
||||||
Tag::Tag()
|
Tag::Tag()
|
||||||
{
|
{
|
||||||
m_Id = 0;
|
m_Id = 0L;
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
m_Name = U("");
|
m_Name = U("");
|
||||||
m_NameIsSet = false;
|
m_NameIsSet = false;
|
||||||
|
@ -21,7 +21,7 @@ namespace model {
|
|||||||
|
|
||||||
User::User()
|
User::User()
|
||||||
{
|
{
|
||||||
m_Id = 0;
|
m_Id = 0L;
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
m_Username = U("");
|
m_Username = U("");
|
||||||
m_UsernameIsSet = false;
|
m_UsernameIsSet = false;
|
||||||
|
@ -2,49 +2,51 @@ PATH
|
|||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
petstore (1.0.0)
|
petstore (1.0.0)
|
||||||
json (~> 1.8, >= 1.8.3)
|
json (~> 2.1, >= 2.1.0)
|
||||||
typhoeus (~> 1.0, >= 1.0.1)
|
typhoeus (~> 1.0, >= 1.0.1)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
ZenTest (4.11.0)
|
ZenTest (4.11.1)
|
||||||
addressable (2.3.8)
|
addressable (2.5.1)
|
||||||
|
public_suffix (~> 2.0, >= 2.0.2)
|
||||||
autotest (4.4.6)
|
autotest (4.4.6)
|
||||||
ZenTest (>= 4.4.1)
|
ZenTest (>= 4.4.1)
|
||||||
autotest-fsevent (0.2.12)
|
autotest-fsevent (0.2.12)
|
||||||
sys-uname
|
sys-uname
|
||||||
autotest-growl (0.2.16)
|
autotest-growl (0.2.16)
|
||||||
autotest-rails-pure (4.1.2)
|
autotest-rails-pure (4.1.2)
|
||||||
crack (0.4.2)
|
crack (0.4.3)
|
||||||
safe_yaml (~> 1.0.0)
|
safe_yaml (~> 1.0.0)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.3)
|
||||||
ethon (0.8.1)
|
ethon (0.10.1)
|
||||||
ffi (>= 1.3.0)
|
ffi (>= 1.3.0)
|
||||||
ffi (1.9.8)
|
ffi (1.9.18)
|
||||||
hashdiff (0.3.0)
|
hashdiff (0.3.4)
|
||||||
json (1.8.3)
|
json (2.1.0)
|
||||||
|
public_suffix (2.0.5)
|
||||||
rake (12.0.0)
|
rake (12.0.0)
|
||||||
rspec (3.4.0)
|
rspec (3.6.0)
|
||||||
rspec-core (~> 3.4.0)
|
rspec-core (~> 3.6.0)
|
||||||
rspec-expectations (~> 3.4.0)
|
rspec-expectations (~> 3.6.0)
|
||||||
rspec-mocks (~> 3.4.0)
|
rspec-mocks (~> 3.6.0)
|
||||||
rspec-core (3.4.4)
|
rspec-core (3.6.0)
|
||||||
rspec-support (~> 3.4.0)
|
rspec-support (~> 3.6.0)
|
||||||
rspec-expectations (3.4.0)
|
rspec-expectations (3.6.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.4.0)
|
rspec-support (~> 3.6.0)
|
||||||
rspec-mocks (3.4.1)
|
rspec-mocks (3.6.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.4.0)
|
rspec-support (~> 3.6.0)
|
||||||
rspec-support (3.4.1)
|
rspec-support (3.6.0)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
sys-uname (1.0.3)
|
sys-uname (1.0.3)
|
||||||
ffi (>= 1.0.0)
|
ffi (>= 1.0.0)
|
||||||
typhoeus (1.0.1)
|
typhoeus (1.1.2)
|
||||||
ethon (>= 0.8.0)
|
ethon (>= 0.9.0)
|
||||||
vcr (3.0.1)
|
vcr (3.0.3)
|
||||||
webmock (1.24.5)
|
webmock (1.24.6)
|
||||||
addressable (>= 2.3.6)
|
addressable (>= 2.3.6)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff
|
hashdiff
|
||||||
@ -59,9 +61,6 @@ DEPENDENCIES
|
|||||||
autotest-rails-pure (~> 4.1, >= 4.1.2)
|
autotest-rails-pure (~> 4.1, >= 4.1.2)
|
||||||
petstore!
|
petstore!
|
||||||
rake (~> 12.0.0)
|
rake (~> 12.0.0)
|
||||||
rspec (~> 3.4, >= 3.4.0)
|
rspec (~> 3.6, >= 3.6.0)
|
||||||
vcr (~> 3.0, >= 3.0.1)
|
vcr (~> 3.0, >= 3.0.1)
|
||||||
webmock (~> 1.24, >= 1.24.3)
|
webmock (~> 1.24, >= 1.24.3)
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.12.3
|
|
||||||
|
@ -274,7 +274,7 @@ double = 1.2 # Float | None
|
|||||||
|
|
||||||
pattern_without_delimiter = "pattern_without_delimiter_example" # String | None
|
pattern_without_delimiter = "pattern_without_delimiter_example" # String | None
|
||||||
|
|
||||||
byte = "B" # String | None
|
byte = "byte_example" # String | None
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
integer: 56, # Integer | None
|
integer: 56, # Integer | None
|
||||||
|
@ -198,6 +198,10 @@ module Petstore
|
|||||||
invalid_properties.push("invalid value for 'byte', byte cannot be nil.")
|
invalid_properties.push("invalid value for 'byte', byte cannot be nil.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
||||||
|
invalid_properties.push("invalid value for 'byte', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.")
|
||||||
|
end
|
||||||
|
|
||||||
if @date.nil?
|
if @date.nil?
|
||||||
invalid_properties.push("invalid value for 'date', date cannot be nil.")
|
invalid_properties.push("invalid value for 'date', date cannot be nil.")
|
||||||
end
|
end
|
||||||
@ -233,6 +237,7 @@ module Petstore
|
|||||||
return false if !@double.nil? && @double < 67.8
|
return false if !@double.nil? && @double < 67.8
|
||||||
return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i)
|
return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i)
|
||||||
return false if @byte.nil?
|
return false if @byte.nil?
|
||||||
|
return false if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
||||||
return false if @date.nil?
|
return false if @date.nil?
|
||||||
return false if @password.nil?
|
return false if @password.nil?
|
||||||
return false if @password.to_s.length > 64
|
return false if @password.to_s.length > 64
|
||||||
@ -329,6 +334,20 @@ module Petstore
|
|||||||
@string = string
|
@string = string
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Custom attribute writer method with validation
|
||||||
|
# @param [Object] byte Value to be assigned
|
||||||
|
def byte=(byte)
|
||||||
|
if byte.nil?
|
||||||
|
fail ArgumentError, "byte cannot be nil"
|
||||||
|
end
|
||||||
|
|
||||||
|
if byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
||||||
|
fail ArgumentError, "invalid value for 'byte', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."
|
||||||
|
end
|
||||||
|
|
||||||
|
@byte = byte
|
||||||
|
end
|
||||||
|
|
||||||
# Custom attribute writer method with validation
|
# Custom attribute writer method with validation
|
||||||
# @param [Object] password Value to be assigned
|
# @param [Object] password Value to be assigned
|
||||||
def password=(password)
|
def password=(password)
|
||||||
|
@ -29,9 +29,9 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = ">= 1.9"
|
s.required_ruby_version = ">= 1.9"
|
||||||
|
|
||||||
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
||||||
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
||||||
|
|
||||||
s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
|
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
||||||
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
||||||
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
|
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
|
||||||
s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
|
s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.4.7.RELEASE</version>
|
<version>1.5.4.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-parent</artifactId>
|
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||||
<version>Camden.SR1</version>
|
<version>Dalston.SR1</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -8,3 +8,4 @@ hystrix.command.default.execution.timeout.enabled: false
|
|||||||
|
|
||||||
logging.level.io.swagger.api: DEBUG
|
logging.level.io.swagger.api: DEBUG
|
||||||
|
|
||||||
|
feign.hystrix.enabled: true
|
||||||
|
@ -42,9 +42,12 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.joschi.jackson</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
<version>2.6.4</version>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>joda-time</groupId>
|
||||||
|
<artifactId>joda-time</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Bean Validation API support -->
|
<!-- Bean Validation API support -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
63
samples/client/petstore/swift3/unwraprequired/.gitignore
vendored
Normal file
63
samples/client/petstore/swift3/unwraprequired/.gitignore
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
## Playgrounds
|
||||||
|
timeline.xctimeline
|
||||||
|
playground.xcworkspace
|
||||||
|
|
||||||
|
# Swift Package Manager
|
||||||
|
#
|
||||||
|
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||||
|
# Packages/
|
||||||
|
.build/
|
||||||
|
|
||||||
|
# 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
|
@ -0,0 +1 @@
|
|||||||
|
2.3.0-SNAPSHOT
|
1
samples/client/petstore/swift3/unwraprequired/Cartfile
Normal file
1
samples/client/petstore/swift3/unwraprequired/Cartfile
Normal file
@ -0,0 +1 @@
|
|||||||
|
github "Alamofire/Alamofire" >= 3.1.0
|
@ -0,0 +1,13 @@
|
|||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'PetstoreClient'
|
||||||
|
s.ios.deployment_target = '9.0'
|
||||||
|
s.osx.deployment_target = '10.11'
|
||||||
|
s.version = '0.0.1'
|
||||||
|
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||||
|
s.authors = ''
|
||||||
|
s.license = 'Proprietary'
|
||||||
|
s.homepage = 'https://github.com/swagger-api/swagger-codegen'
|
||||||
|
s.summary = 'PetstoreClient'
|
||||||
|
s.source_files = 'PetstoreClient/Classes/Swaggers/**/*.swift'
|
||||||
|
s.dependency 'Alamofire', '~> 4.0'
|
||||||
|
end
|
@ -0,0 +1,79 @@
|
|||||||
|
// APIHelper.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class APIHelper {
|
||||||
|
static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
|
||||||
|
var destination = [String:Any]()
|
||||||
|
for (key, nillableValue) in source {
|
||||||
|
if let value: Any = nillableValue {
|
||||||
|
destination[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if destination.isEmpty {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return destination
|
||||||
|
}
|
||||||
|
|
||||||
|
static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
|
||||||
|
var destination = [String:String]()
|
||||||
|
for (key, nillableValue) in source {
|
||||||
|
if let value: Any = nillableValue {
|
||||||
|
destination[key] = "\(value)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return destination
|
||||||
|
}
|
||||||
|
|
||||||
|
static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
|
||||||
|
guard let source = source else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var destination = [String:Any]()
|
||||||
|
let theTrue = NSNumber(value: true as Bool)
|
||||||
|
let theFalse = NSNumber(value: false as Bool)
|
||||||
|
for (key, value) in source {
|
||||||
|
switch value {
|
||||||
|
case let x where x as? NSNumber === theTrue || x as? NSNumber === theFalse:
|
||||||
|
destination[key] = "\(value as! Bool)" as Any?
|
||||||
|
default:
|
||||||
|
destination[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return destination
|
||||||
|
}
|
||||||
|
|
||||||
|
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
||||||
|
let returnValues = values
|
||||||
|
.filter { $0.1 != nil }
|
||||||
|
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||||
|
if let value = item._value as? Array<String> {
|
||||||
|
return value.map { (v) -> URLQueryItem in
|
||||||
|
URLQueryItem(
|
||||||
|
name: item._key,
|
||||||
|
value: v
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return [URLQueryItem(
|
||||||
|
name: item._key,
|
||||||
|
value: "\(item._value!)"
|
||||||
|
)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.flatMap { $0 }
|
||||||
|
|
||||||
|
if returnValues.count == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValues
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
// APIs.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
open class PetstoreClientAPI {
|
||||||
|
open static var basePath = "http://petstore.swagger.io:80/v2"
|
||||||
|
open static var credential: URLCredential?
|
||||||
|
open static var customHeaders: [String:String] = [:]
|
||||||
|
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
|
||||||
|
}
|
||||||
|
|
||||||
|
open class APIBase {
|
||||||
|
func toParameters(_ encodable: JSONEncodable?) -> [String: Any]? {
|
||||||
|
let encoded: Any? = encodable?.encodeToJSON()
|
||||||
|
|
||||||
|
if encoded! is [Any] {
|
||||||
|
var dictionary = [String:Any]()
|
||||||
|
for (index, item) in (encoded as! [Any]).enumerated() {
|
||||||
|
dictionary["\(index)"] = item
|
||||||
|
}
|
||||||
|
return dictionary
|
||||||
|
} else {
|
||||||
|
return encoded as? [String:Any]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class RequestBuilder<T> {
|
||||||
|
var credential: URLCredential?
|
||||||
|
var headers: [String:String]
|
||||||
|
let parameters: [String:Any]?
|
||||||
|
let isBody: Bool
|
||||||
|
let method: String
|
||||||
|
let URLString: String
|
||||||
|
|
||||||
|
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||||
|
public var onProgressReady: ((Progress) -> ())?
|
||||||
|
|
||||||
|
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
|
||||||
|
self.method = method
|
||||||
|
self.URLString = URLString
|
||||||
|
self.parameters = parameters
|
||||||
|
self.isBody = isBody
|
||||||
|
self.headers = headers
|
||||||
|
|
||||||
|
addHeaders(PetstoreClientAPI.customHeaders)
|
||||||
|
}
|
||||||
|
|
||||||
|
open func addHeaders(_ aHeaders:[String:String]) {
|
||||||
|
for (header, value) in aHeaders {
|
||||||
|
headers[header] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: ErrorResponse?) -> Void) { }
|
||||||
|
|
||||||
|
public func addHeader(name: String, value: String) -> Self {
|
||||||
|
if !value.isEmpty {
|
||||||
|
headers[name] = value
|
||||||
|
}
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
open func addCredential() -> Self {
|
||||||
|
self.credential = PetstoreClientAPI.credential
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public protocol RequestBuilderFactory {
|
||||||
|
func getBuilder<T>() -> RequestBuilder<T>.Type
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,424 @@
|
|||||||
|
//
|
||||||
|
// FakeAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
open class FakeAPI: APIBase {
|
||||||
|
/**
|
||||||
|
- parameter body: (body) Input boolean as post body (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func fakeOuterBooleanSerialize(body: OuterBoolean? = nil, completion: @escaping ((_ data: OuterBoolean?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
- POST /fake/outer/boolean
|
||||||
|
- Test serialization of outer boolean types
|
||||||
|
|
||||||
|
- examples: [{contentType=application/json, example={ }}]
|
||||||
|
- parameter body: (body) Input boolean as post body (optional)
|
||||||
|
- returns: RequestBuilder<OuterBoolean>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterBooleanSerializeWithRequestBuilder(body: OuterBoolean? = nil) -> RequestBuilder<OuterBoolean> {
|
||||||
|
let path = "/fake/outer/boolean"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body?.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterBoolean>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
- parameter body: (body) Input composite as post body (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
- POST /fake/outer/composite
|
||||||
|
- Test serialization of object with outer number type
|
||||||
|
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"my_string" : { },
|
||||||
|
"my_number" : { },
|
||||||
|
"my_boolean" : { }
|
||||||
|
}}]
|
||||||
|
- parameter body: (body) Input composite as post body (optional)
|
||||||
|
- returns: RequestBuilder<OuterComposite>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterCompositeSerializeWithRequestBuilder(body: OuterComposite? = nil) -> RequestBuilder<OuterComposite> {
|
||||||
|
let path = "/fake/outer/composite"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body?.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterComposite>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
- parameter body: (body) Input number as post body (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func fakeOuterNumberSerialize(body: OuterNumber? = nil, completion: @escaping ((_ data: OuterNumber?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
- POST /fake/outer/number
|
||||||
|
- Test serialization of outer number types
|
||||||
|
|
||||||
|
- examples: [{contentType=application/json, example={ }}]
|
||||||
|
- parameter body: (body) Input number as post body (optional)
|
||||||
|
- returns: RequestBuilder<OuterNumber>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterNumberSerializeWithRequestBuilder(body: OuterNumber? = nil) -> RequestBuilder<OuterNumber> {
|
||||||
|
let path = "/fake/outer/number"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body?.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterNumber>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
- parameter body: (body) Input string as post body (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func fakeOuterStringSerialize(body: OuterString? = nil, completion: @escaping ((_ data: OuterString?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
- POST /fake/outer/string
|
||||||
|
- Test serialization of outer string types
|
||||||
|
|
||||||
|
- examples: [{contentType=application/json, example={ }}]
|
||||||
|
- parameter body: (body) Input string as post body (optional)
|
||||||
|
- returns: RequestBuilder<OuterString>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterStringSerializeWithRequestBuilder(body: OuterString? = nil) -> RequestBuilder<OuterString> {
|
||||||
|
let path = "/fake/outer/string"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body?.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterString>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test \"client\" model
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testClientModel(body: Client, completion: @escaping ((_ data: Client?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
testClientModelWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test \"client\" model
|
||||||
|
- PATCH /fake
|
||||||
|
- To test \"client\" model
|
||||||
|
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "aeiou"
|
||||||
|
}}]
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testClientModelWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/fake"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
- parameter number: (form) None
|
||||||
|
- parameter double: (form) None
|
||||||
|
- parameter patternWithoutDelimiter: (form) None
|
||||||
|
- parameter byte: (form) None
|
||||||
|
- parameter integer: (form) None (optional)
|
||||||
|
- parameter int32: (form) None (optional)
|
||||||
|
- parameter int64: (form) None (optional)
|
||||||
|
- parameter float: (form) None (optional)
|
||||||
|
- parameter string: (form) None (optional)
|
||||||
|
- parameter binary: (form) None (optional)
|
||||||
|
- parameter date: (form) None (optional)
|
||||||
|
- parameter dateTime: (form) None (optional)
|
||||||
|
- parameter password: (form) None (optional)
|
||||||
|
- parameter callback: (form) None (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int32? = nil, int32: Int32? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: ISOFullDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
- POST /fake
|
||||||
|
- Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
- BASIC:
|
||||||
|
- type: basic
|
||||||
|
- name: http_basic_test
|
||||||
|
- parameter number: (form) None
|
||||||
|
- parameter double: (form) None
|
||||||
|
- parameter patternWithoutDelimiter: (form) None
|
||||||
|
- parameter byte: (form) None
|
||||||
|
- parameter integer: (form) None (optional)
|
||||||
|
- parameter int32: (form) None (optional)
|
||||||
|
- parameter int64: (form) None (optional)
|
||||||
|
- parameter float: (form) None (optional)
|
||||||
|
- parameter string: (form) None (optional)
|
||||||
|
- parameter binary: (form) None (optional)
|
||||||
|
- parameter date: (form) None (optional)
|
||||||
|
- parameter dateTime: (form) None (optional)
|
||||||
|
- parameter password: (form) None (optional)
|
||||||
|
- parameter callback: (form) None (optional)
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int32? = nil, int32: Int32? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: ISOFullDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||||
|
let path = "/fake"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"integer": integer?.encodeToJSON(),
|
||||||
|
"int32": int32?.encodeToJSON(),
|
||||||
|
"int64": int64?.encodeToJSON(),
|
||||||
|
"number": number,
|
||||||
|
"float": float,
|
||||||
|
"double": double,
|
||||||
|
"string": string,
|
||||||
|
"pattern_without_delimiter": patternWithoutDelimiter,
|
||||||
|
"byte": byte,
|
||||||
|
"binary": binary,
|
||||||
|
"date": date?.encodeToJSON(),
|
||||||
|
"dateTime": dateTime?.encodeToJSON(),
|
||||||
|
"password": password,
|
||||||
|
"callback": callback
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumFormStringArray
|
||||||
|
*/
|
||||||
|
public enum EnumFormStringArray_testEnumParameters: String {
|
||||||
|
case greaterThan = ">"
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumFormString
|
||||||
|
*/
|
||||||
|
public enum EnumFormString_testEnumParameters: String {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumHeaderStringArray
|
||||||
|
*/
|
||||||
|
public enum EnumHeaderStringArray_testEnumParameters: String {
|
||||||
|
case greaterThan = ">"
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumHeaderString
|
||||||
|
*/
|
||||||
|
public enum EnumHeaderString_testEnumParameters: String {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryStringArray
|
||||||
|
*/
|
||||||
|
public enum EnumQueryStringArray_testEnumParameters: String {
|
||||||
|
case greaterThan = ">"
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryString
|
||||||
|
*/
|
||||||
|
public enum EnumQueryString_testEnumParameters: String {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryInteger
|
||||||
|
*/
|
||||||
|
public enum EnumQueryInteger_testEnumParameters: Int32 {
|
||||||
|
case _1 = 1
|
||||||
|
case numberminus2 = -2
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryDouble
|
||||||
|
*/
|
||||||
|
public enum EnumQueryDouble_testEnumParameters: Double {
|
||||||
|
case _11 = 1.1
|
||||||
|
case numberminus12 = -1.2
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test enum parameters
|
||||||
|
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional)
|
||||||
|
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||||
|
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||||
|
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||||
|
- parameter enumQueryDouble: (form) Query parameter enum test (double) (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testEnumParameters(enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
testEnumParametersWithRequestBuilder(enumFormStringArray: enumFormStringArray, enumFormString: enumFormString, enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test enum parameters
|
||||||
|
- GET /fake
|
||||||
|
- To test enum parameters
|
||||||
|
|
||||||
|
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional)
|
||||||
|
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||||
|
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||||
|
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||||
|
- parameter enumQueryDouble: (form) Query parameter enum test (double) (optional)
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func testEnumParametersWithRequestBuilder(enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil) -> RequestBuilder<Void> {
|
||||||
|
let path = "/fake"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"enum_form_string_array": enumFormStringArray,
|
||||||
|
"enum_form_string": enumFormString?.rawValue,
|
||||||
|
"enum_query_double": enumQueryDouble?.rawValue
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"enum_query_string_array": enumQueryStringArray,
|
||||||
|
"enum_query_string": enumQueryString?.rawValue,
|
||||||
|
"enum_query_integer": enumQueryInteger?.rawValue
|
||||||
|
])
|
||||||
|
let nillableHeaders: [String: Any?] = [
|
||||||
|
"enum_header_string_array": enumHeaderStringArray,
|
||||||
|
"enum_header_string": enumHeaderString?.rawValue
|
||||||
|
]
|
||||||
|
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
test json serialization of form data
|
||||||
|
- parameter param: (form) field1
|
||||||
|
- parameter param2: (form) field2
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
test json serialization of form data
|
||||||
|
- GET /fake/jsonFormData
|
||||||
|
-
|
||||||
|
|
||||||
|
- parameter param: (form) field1
|
||||||
|
- parameter param2: (form) field2
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder<Void> {
|
||||||
|
let path = "/fake/jsonFormData"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"param": param,
|
||||||
|
"param2": param2
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
//
|
||||||
|
// Fake_classname_tags123API.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
open class Fake_classname_tags123API: APIBase {
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
- PATCH /fake_classname_test
|
||||||
|
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "aeiou"
|
||||||
|
}}]
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/fake_classname_test"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,473 @@
|
|||||||
|
//
|
||||||
|
// PetAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
open class PetAPI: APIBase {
|
||||||
|
/**
|
||||||
|
Add a new pet to the store
|
||||||
|
- parameter body: (body) Pet object that needs to be added to the store
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func addPet(body: Pet, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Add a new pet to the store
|
||||||
|
- POST /pet
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- parameter body: (body) Pet object that needs to be added to the store
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func addPetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||||
|
let path = "/pet"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes a pet
|
||||||
|
- parameter petId: (path) Pet id to delete
|
||||||
|
- parameter apiKey: (header) (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes a pet
|
||||||
|
- DELETE /pet/{petId}
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- parameter petId: (path) Pet id to delete
|
||||||
|
- parameter apiKey: (header) (optional)
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
|
||||||
|
var path = "/pet/{petId}"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
let nillableHeaders: [String: Any?] = [
|
||||||
|
"api_key": apiKey
|
||||||
|
]
|
||||||
|
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter status
|
||||||
|
*/
|
||||||
|
public enum Status_findPetsByStatus: String {
|
||||||
|
case available = "available"
|
||||||
|
case pending = "pending"
|
||||||
|
case sold = "sold"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Finds Pets by status
|
||||||
|
- parameter status: (query) Status values that need to be considered for filter
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Finds Pets by status
|
||||||
|
- GET /pet/findByStatus
|
||||||
|
- Multiple status values can be provided with comma separated strings
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
- parameter status: (query) Status values that need to be considered for filter
|
||||||
|
- returns: RequestBuilder<[Pet]>
|
||||||
|
*/
|
||||||
|
open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> {
|
||||||
|
let path = "/pet/findByStatus"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"status": status
|
||||||
|
])
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Finds Pets by tags
|
||||||
|
- parameter tags: (query) Tags to filter by
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Finds Pets by tags
|
||||||
|
- GET /pet/findByTags
|
||||||
|
- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
- parameter tags: (query) Tags to filter by
|
||||||
|
- returns: RequestBuilder<[Pet]>
|
||||||
|
*/
|
||||||
|
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
|
||||||
|
let path = "/pet/findByTags"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"tags": tags
|
||||||
|
])
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find pet by ID
|
||||||
|
- parameter petId: (path) ID of pet to return
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find pet by ID
|
||||||
|
- GET /pet/{petId}
|
||||||
|
- Returns a single pet
|
||||||
|
- API Key:
|
||||||
|
- type: apiKey api_key
|
||||||
|
- name: api_key
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example={
|
||||||
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example={
|
||||||
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "aeiou",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}}]
|
||||||
|
- parameter petId: (path) ID of pet to return
|
||||||
|
- returns: RequestBuilder<Pet>
|
||||||
|
*/
|
||||||
|
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
|
||||||
|
var path = "/pet/{petId}"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update an existing pet
|
||||||
|
- parameter body: (body) Pet object that needs to be added to the store
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func updatePet(body: Pet, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update an existing pet
|
||||||
|
- PUT /pet
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- parameter body: (body) Pet object that needs to be added to the store
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func updatePetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||||
|
let path = "/pet"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates a pet in the store with form data
|
||||||
|
- parameter petId: (path) ID of pet that needs to be updated
|
||||||
|
- parameter name: (form) Updated name of the pet (optional)
|
||||||
|
- parameter status: (form) Updated status of the pet (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates a pet in the store with form data
|
||||||
|
- POST /pet/{petId}
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- parameter petId: (path) ID of pet that needs to be updated
|
||||||
|
- parameter name: (form) Updated name of the pet (optional)
|
||||||
|
- parameter status: (form) Updated status of the pet (optional)
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
|
||||||
|
var path = "/pet/{petId}"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"name": name,
|
||||||
|
"status": status
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
uploads an image
|
||||||
|
- parameter petId: (path) ID of pet to update
|
||||||
|
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||||
|
- parameter file: (form) file to upload (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
uploads an image
|
||||||
|
- POST /pet/{petId}/uploadImage
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"code" : 0,
|
||||||
|
"type" : "aeiou",
|
||||||
|
"message" : "aeiou"
|
||||||
|
}}]
|
||||||
|
- parameter petId: (path) ID of pet to update
|
||||||
|
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||||
|
- parameter file: (form) file to upload (optional)
|
||||||
|
- returns: RequestBuilder<ApiResponse>
|
||||||
|
*/
|
||||||
|
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
|
||||||
|
var path = "/pet/{petId}/uploadImage"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"additionalMetadata": additionalMetadata,
|
||||||
|
"file": file
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,206 @@
|
|||||||
|
//
|
||||||
|
// StoreAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
open class StoreAPI: APIBase {
|
||||||
|
/**
|
||||||
|
Delete purchase order by ID
|
||||||
|
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func deleteOrder(orderId: String, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Delete purchase order by ID
|
||||||
|
- DELETE /store/order/{order_id}
|
||||||
|
- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
|
||||||
|
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
|
||||||
|
var path = "/store/order/{order_id}"
|
||||||
|
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns pet inventories by status
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func getInventory(completion: @escaping ((_ data: [String:Int32]?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
getInventoryWithRequestBuilder().execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns pet inventories by status
|
||||||
|
- GET /store/inventory
|
||||||
|
- Returns a map of status codes to quantities
|
||||||
|
- API Key:
|
||||||
|
- type: apiKey api_key
|
||||||
|
- name: api_key
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"key" : 0
|
||||||
|
}}]
|
||||||
|
- returns: RequestBuilder<[String:Int32]>
|
||||||
|
*/
|
||||||
|
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int32]> {
|
||||||
|
let path = "/store/inventory"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<[String:Int32]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find purchase order by ID
|
||||||
|
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find purchase order by ID
|
||||||
|
- GET /store/order/{order_id}
|
||||||
|
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||||
|
- returns: RequestBuilder<Order>
|
||||||
|
*/
|
||||||
|
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
|
||||||
|
var path = "/store/order/{order_id}"
|
||||||
|
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Place an order for a pet
|
||||||
|
- parameter body: (body) order placed for purchasing the pet
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func placeOrder(body: Order, completion: @escaping ((_ data: Order?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Place an order for a pet
|
||||||
|
- POST /store/order
|
||||||
|
-
|
||||||
|
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
- parameter body: (body) order placed for purchasing the pet
|
||||||
|
- returns: RequestBuilder<Order>
|
||||||
|
*/
|
||||||
|
open class func placeOrderWithRequestBuilder(body: Order) -> RequestBuilder<Order> {
|
||||||
|
let path = "/store/order"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,320 @@
|
|||||||
|
//
|
||||||
|
// UserAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
open class UserAPI: APIBase {
|
||||||
|
/**
|
||||||
|
Create user
|
||||||
|
- parameter body: (body) Created user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func createUser(body: User, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
createUserWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create user
|
||||||
|
- POST /user
|
||||||
|
- This can only be done by the logged in user.
|
||||||
|
|
||||||
|
- parameter body: (body) Created user object
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func createUserWithRequestBuilder(body: User) -> RequestBuilder<Void> {
|
||||||
|
let path = "/user"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func createUsersWithArrayInput(body: [User], completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
createUsersWithArrayInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
- POST /user/createWithArray
|
||||||
|
-
|
||||||
|
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func createUsersWithArrayInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||||
|
let path = "/user/createWithArray"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func createUsersWithListInput(body: [User], completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
createUsersWithListInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
- POST /user/createWithList
|
||||||
|
-
|
||||||
|
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func createUsersWithListInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||||
|
let path = "/user/createWithList"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Delete user
|
||||||
|
- parameter username: (path) The name that needs to be deleted
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func deleteUser(username: String, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Delete user
|
||||||
|
- DELETE /user/{username}
|
||||||
|
- This can only be done by the logged in user.
|
||||||
|
|
||||||
|
- parameter username: (path) The name that needs to be deleted
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
|
||||||
|
var path = "/user/{username}"
|
||||||
|
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get user by user name
|
||||||
|
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func getUserByName(username: String, completion: @escaping ((_ data: User?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get user by user name
|
||||||
|
- GET /user/{username}
|
||||||
|
-
|
||||||
|
|
||||||
|
- examples: [{contentType=application/xml, example=<User>
|
||||||
|
<id>123456789</id>
|
||||||
|
<username>aeiou</username>
|
||||||
|
<firstName>aeiou</firstName>
|
||||||
|
<lastName>aeiou</lastName>
|
||||||
|
<email>aeiou</email>
|
||||||
|
<password>aeiou</password>
|
||||||
|
<phone>aeiou</phone>
|
||||||
|
<userStatus>123</userStatus>
|
||||||
|
</User>}, {contentType=application/json, example={
|
||||||
|
"firstName" : "aeiou",
|
||||||
|
"lastName" : "aeiou",
|
||||||
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 6,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 0,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<User>
|
||||||
|
<id>123456789</id>
|
||||||
|
<username>aeiou</username>
|
||||||
|
<firstName>aeiou</firstName>
|
||||||
|
<lastName>aeiou</lastName>
|
||||||
|
<email>aeiou</email>
|
||||||
|
<password>aeiou</password>
|
||||||
|
<phone>aeiou</phone>
|
||||||
|
<userStatus>123</userStatus>
|
||||||
|
</User>}, {contentType=application/json, example={
|
||||||
|
"firstName" : "aeiou",
|
||||||
|
"lastName" : "aeiou",
|
||||||
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 6,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 0,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}]
|
||||||
|
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||||
|
- returns: RequestBuilder<User>
|
||||||
|
*/
|
||||||
|
open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder<User> {
|
||||||
|
var path = "/user/{username}"
|
||||||
|
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs user into the system
|
||||||
|
- parameter username: (query) The user name for login
|
||||||
|
- parameter password: (query) The password for login in clear text
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?, _ error: ErrorResponse?) -> Void)) {
|
||||||
|
loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs user into the system
|
||||||
|
- GET /user/login
|
||||||
|
-
|
||||||
|
|
||||||
|
- responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)]
|
||||||
|
- responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)]
|
||||||
|
- examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}]
|
||||||
|
- examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}]
|
||||||
|
- parameter username: (query) The user name for login
|
||||||
|
- parameter password: (query) The password for login in clear text
|
||||||
|
- returns: RequestBuilder<String>
|
||||||
|
*/
|
||||||
|
open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder<String> {
|
||||||
|
let path = "/user/login"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"username": username,
|
||||||
|
"password": password
|
||||||
|
])
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs out current logged in user session
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func logoutUser(completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
logoutUserWithRequestBuilder().execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs out current logged in user session
|
||||||
|
- GET /user/logout
|
||||||
|
-
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
|
||||||
|
let path = "/user/logout"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updated user
|
||||||
|
- parameter username: (path) name that need to be deleted
|
||||||
|
- parameter body: (body) Updated user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func updateUser(username: String, body: User, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||||
|
updateUserWithRequestBuilder(username: username, body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updated user
|
||||||
|
- PUT /user/{username}
|
||||||
|
- This can only be done by the logged in user.
|
||||||
|
|
||||||
|
- parameter username: (path) name that need to be deleted
|
||||||
|
- parameter body: (body) Updated user object
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func updateUserWithRequestBuilder(username: String, body: User) -> RequestBuilder<Void> {
|
||||||
|
var path = "/user/{username}"
|
||||||
|
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = body.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,256 @@
|
|||||||
|
// AlamofireImplementations.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
func getBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
|
return AlamofireRequestBuilder<T>.self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct SynchronizedDictionary<K: Hashable, V> {
|
||||||
|
|
||||||
|
private var dictionary = [K: V]()
|
||||||
|
private let queue = DispatchQueue(
|
||||||
|
label: "SynchronizedDictionary",
|
||||||
|
qos: DispatchQoS.userInitiated,
|
||||||
|
attributes: [DispatchQueue.Attributes.concurrent],
|
||||||
|
autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit,
|
||||||
|
target: nil
|
||||||
|
)
|
||||||
|
|
||||||
|
public subscript(key: K) -> V? {
|
||||||
|
get {
|
||||||
|
var value: V?
|
||||||
|
|
||||||
|
queue.sync {
|
||||||
|
value = self.dictionary[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
queue.sync(flags: DispatchWorkItemFlags.barrier) {
|
||||||
|
self.dictionary[key] = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store manager to retain its reference
|
||||||
|
private var managerStore = SynchronizedDictionary<String, Alamofire.SessionManager>()
|
||||||
|
|
||||||
|
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||||
|
required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
|
||||||
|
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
May be overridden by a subclass if you want to control the session
|
||||||
|
configuration.
|
||||||
|
*/
|
||||||
|
open func createSessionManager() -> Alamofire.SessionManager {
|
||||||
|
let configuration = URLSessionConfiguration.default
|
||||||
|
configuration.httpAdditionalHeaders = buildHeaders()
|
||||||
|
return Alamofire.SessionManager(configuration: configuration)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
May be overridden by a subclass if you want to control the Content-Type
|
||||||
|
that is given to an uploaded form part.
|
||||||
|
|
||||||
|
Return nil to use the default behavior (inferring the Content-Type from
|
||||||
|
the file extension). Return the desired Content-Type otherwise.
|
||||||
|
*/
|
||||||
|
open func contentTypeForFormPart(fileURL: URL) -> String? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
May be overridden by a subclass if you want to control the request
|
||||||
|
configuration (e.g. to override the cache policy).
|
||||||
|
*/
|
||||||
|
open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String:String]) -> DataRequest {
|
||||||
|
return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
override open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: ErrorResponse?) -> Void) {
|
||||||
|
let managerId:String = UUID().uuidString
|
||||||
|
// Create a new manager for each request to customize its request header
|
||||||
|
let manager = createSessionManager()
|
||||||
|
managerStore[managerId] = manager
|
||||||
|
|
||||||
|
let encoding:ParameterEncoding = isBody ? JSONEncoding() : URLEncoding()
|
||||||
|
|
||||||
|
let xMethod = Alamofire.HTTPMethod(rawValue: method)
|
||||||
|
let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL }
|
||||||
|
.map { $0.0 }
|
||||||
|
|
||||||
|
if fileKeys.count > 0 {
|
||||||
|
manager.upload(multipartFormData: { mpForm in
|
||||||
|
for (k, v) in self.parameters! {
|
||||||
|
switch v {
|
||||||
|
case let fileURL as URL:
|
||||||
|
if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) {
|
||||||
|
mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mpForm.append(fileURL, withName: k)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case let string as String:
|
||||||
|
mpForm.append(string.data(using: String.Encoding.utf8)!, withName: k)
|
||||||
|
break
|
||||||
|
case let number as NSNumber:
|
||||||
|
mpForm.append(number.stringValue.data(using: String.Encoding.utf8)!, withName: k)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
fatalError("Unprocessable value \(v) with key \(k)")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in
|
||||||
|
switch encodingResult {
|
||||||
|
case .success(let upload, _, _):
|
||||||
|
if let onProgressReady = self.onProgressReady {
|
||||||
|
onProgressReady(upload.uploadProgress)
|
||||||
|
}
|
||||||
|
self.processRequest(request: upload, managerId, completion)
|
||||||
|
case .failure(let encodingError):
|
||||||
|
completion(nil, ErrorResponse.HttpError(statusCode: 415, data: nil, error: encodingError))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
let request = makeRequest(manager: manager, method: xMethod!, encoding: encoding, headers: headers)
|
||||||
|
if let onProgressReady = self.onProgressReady {
|
||||||
|
onProgressReady(request.progress)
|
||||||
|
}
|
||||||
|
processRequest(request: request, managerId, completion)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: ErrorResponse?) -> Void) {
|
||||||
|
if let credential = self.credential {
|
||||||
|
request.authenticate(usingCredential: credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
let cleanupRequest = {
|
||||||
|
managerStore[managerId] = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
let validatedRequest = request.validate()
|
||||||
|
|
||||||
|
switch T.self {
|
||||||
|
case is String.Type:
|
||||||
|
validatedRequest.responseString(completionHandler: { (stringResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if stringResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.HttpError(statusCode: stringResponse.response?.statusCode ?? 500, data: stringResponse.data, error: stringResponse.result.error as Error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: stringResponse.response!,
|
||||||
|
body: ((stringResponse.result.value ?? "") as! T)
|
||||||
|
),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
case is Void.Type:
|
||||||
|
validatedRequest.responseData(completionHandler: { (voidResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if voidResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.HttpError(statusCode: voidResponse.response?.statusCode ?? 500, data: voidResponse.data, error: voidResponse.result.error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: voidResponse.response!,
|
||||||
|
body: nil),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
case is Data.Type:
|
||||||
|
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if (dataResponse.result.isFailure) {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.HttpError(statusCode: dataResponse.response?.statusCode ?? 500, data: dataResponse.data, error: dataResponse.result.error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: dataResponse.response!,
|
||||||
|
body: (dataResponse.data as! T)
|
||||||
|
),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
validatedRequest.responseJSON(options: .allowFragments) { response in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if response.result.isFailure {
|
||||||
|
completion(nil, ErrorResponse.HttpError(statusCode: response.response?.statusCode ?? 500, data: response.data, error: response.result.error!))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle HTTP 204 No Content
|
||||||
|
// NSNull would crash decoders
|
||||||
|
if response.response?.statusCode == 204 && response.result.value is NSNull{
|
||||||
|
completion(nil, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if () is T {
|
||||||
|
completion(Response(response: response.response!, body: (() as! T)), nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let json: Any = response.result.value {
|
||||||
|
let decoded = Decoders.decode(clazz: T.self, source: json as AnyObject, instance: nil)
|
||||||
|
switch decoded {
|
||||||
|
case let .success(object): completion(Response(response: response.response!, body: object), nil)
|
||||||
|
case let .failure(error): completion(nil, ErrorResponse.DecodeError(response: response.data, decodeError: error))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} else if "" is T {
|
||||||
|
// swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release
|
||||||
|
// https://github.com/swagger-api/swagger-parser/pull/34
|
||||||
|
completion(Response(response: response.response!, body: ("" as! T)), nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(nil, ErrorResponse.HttpError(statusCode: 500, data: nil, error: NSError(domain: "localhost", code: 500, userInfo: ["reason": "unreacheable code"])))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open func buildHeaders() -> [String: String] {
|
||||||
|
var httpHeaders = SessionManager.defaultHTTPHeaders
|
||||||
|
for (key, value) in self.headers {
|
||||||
|
httpHeaders[key] = value
|
||||||
|
}
|
||||||
|
return httpHeaders
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,187 @@
|
|||||||
|
// Extensions.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
extension Bool: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int32: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return NSNumber(value: self as Int32) }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int64: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return NSNumber(value: self as Int64) }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension String: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
private func encodeIfPossible<T>(_ object: T) -> Any {
|
||||||
|
if let encodableObject = object as? JSONEncodable {
|
||||||
|
return encodableObject.encodeToJSON()
|
||||||
|
} else {
|
||||||
|
return object as Any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Array: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return self.map(encodeIfPossible)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Dictionary: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
var dictionary = [AnyHashable: Any]()
|
||||||
|
for (key, value) in self {
|
||||||
|
dictionary[key as! NSObject] = encodeIfPossible(value)
|
||||||
|
}
|
||||||
|
return dictionary as Any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Data: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private let dateFormatter: DateFormatter = {
|
||||||
|
let fmt = DateFormatter()
|
||||||
|
fmt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||||
|
fmt.locale = Locale(identifier: "en_US_POSIX")
|
||||||
|
return fmt
|
||||||
|
}()
|
||||||
|
|
||||||
|
extension Date: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return dateFormatter.string(from: self) as Any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UUID: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return self.uuidString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Represents an ISO-8601 full-date (RFC-3339).
|
||||||
|
/// ex: 12-31-1999
|
||||||
|
/// https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14
|
||||||
|
public final class ISOFullDate: CustomStringConvertible {
|
||||||
|
|
||||||
|
public let year: Int
|
||||||
|
public let month: Int
|
||||||
|
public let day: Int
|
||||||
|
|
||||||
|
public init(year: Int, month: Int, day: Int) {
|
||||||
|
self.year = year
|
||||||
|
self.month = month
|
||||||
|
self.day = day
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a Date to an ISOFullDate. Only interested in the year, month, day components.
|
||||||
|
|
||||||
|
- parameter date: The date to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the year, month, day of the date.
|
||||||
|
*/
|
||||||
|
public static func from(date: Date) -> ISOFullDate? {
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
|
||||||
|
let components = calendar.dateComponents(
|
||||||
|
[
|
||||||
|
.year,
|
||||||
|
.month,
|
||||||
|
.day,
|
||||||
|
],
|
||||||
|
from: date
|
||||||
|
)
|
||||||
|
|
||||||
|
guard
|
||||||
|
let year = components.year,
|
||||||
|
let month = components.month,
|
||||||
|
let day = components.day
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: year,
|
||||||
|
month: month,
|
||||||
|
day: day
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts a ISO-8601 full-date string to an ISOFullDate.
|
||||||
|
|
||||||
|
- parameter string: The ISO-8601 full-date format string to convert.
|
||||||
|
|
||||||
|
- returns: An ISOFullDate constructed from the string.
|
||||||
|
*/
|
||||||
|
public static func from(string: String) -> ISOFullDate? {
|
||||||
|
let components = string
|
||||||
|
.characters
|
||||||
|
.split(separator: "-")
|
||||||
|
.map(String.init)
|
||||||
|
.flatMap { Int($0) }
|
||||||
|
guard components.count == 3 else { return nil }
|
||||||
|
|
||||||
|
return ISOFullDate(
|
||||||
|
year: components[0],
|
||||||
|
month: components[1],
|
||||||
|
day: components[2]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts the receiver to a Date, in the default time zone.
|
||||||
|
|
||||||
|
- returns: A Date from the components of the receiver, in the default time zone.
|
||||||
|
*/
|
||||||
|
public func toDate() -> Date? {
|
||||||
|
var components = DateComponents()
|
||||||
|
components.year = year
|
||||||
|
components.month = month
|
||||||
|
components.day = day
|
||||||
|
components.timeZone = TimeZone.ReferenceType.default
|
||||||
|
let calendar = Calendar(identifier: .gregorian)
|
||||||
|
return calendar.date(from: components)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
|
public var description: String {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ISOFullDate: JSONEncodable {
|
||||||
|
public func encodeToJSON() -> Any {
|
||||||
|
return "\(year)-\(month)-\(day)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,951 @@
|
|||||||
|
// Models.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ErrorResponse : Error {
|
||||||
|
case HttpError(statusCode: Int, data: Data?, error: Error)
|
||||||
|
case DecodeError(response: Data?, decodeError: DecodeError)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Response<T> {
|
||||||
|
open let statusCode: Int
|
||||||
|
open let header: [String: String]
|
||||||
|
open let body: T?
|
||||||
|
|
||||||
|
public init(statusCode: Int, header: [String: String], body: T?) {
|
||||||
|
self.statusCode = statusCode
|
||||||
|
self.header = header
|
||||||
|
self.body = body
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(response: HTTPURLResponse, body: T?) {
|
||||||
|
let rawHeader = response.allHeaderFields
|
||||||
|
var header = [String:String]()
|
||||||
|
for (key, value) in rawHeader {
|
||||||
|
header[key as! String] = value as? String
|
||||||
|
}
|
||||||
|
self.init(statusCode: response.statusCode, header: header, body: body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Decoded<ValueType> {
|
||||||
|
case success(ValueType)
|
||||||
|
case failure(DecodeError)
|
||||||
|
}
|
||||||
|
|
||||||
|
public extension Decoded {
|
||||||
|
var value: ValueType? {
|
||||||
|
switch self {
|
||||||
|
case let .success(value):
|
||||||
|
return value
|
||||||
|
case .failure:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DecodeError {
|
||||||
|
case typeMismatch(expected: String, actual: String)
|
||||||
|
case missingKey(key: String)
|
||||||
|
case parseError(message: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var once = Int()
|
||||||
|
class Decoders {
|
||||||
|
static fileprivate var decoders = Dictionary<String, ((AnyObject, AnyObject?) -> AnyObject)>()
|
||||||
|
|
||||||
|
static func addDecoder<T>(clazz: T.Type, decoder: @escaping ((AnyObject, AnyObject?) -> Decoded<T>)) {
|
||||||
|
let key = "\(T.self)"
|
||||||
|
decoders[key] = { decoder($0, $1) as AnyObject }
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decode<T>(clazz: T.Type, discriminator: String, source: AnyObject) -> Decoded<T> {
|
||||||
|
let key = discriminator
|
||||||
|
if let decoder = decoders[key], let value = decoder(source, nil) as? Decoded<T> {
|
||||||
|
return value
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decode<T>(clazz: [T].Type, source: AnyObject) -> Decoded<[T]> {
|
||||||
|
if let sourceArray = source as? [AnyObject] {
|
||||||
|
var values = [T]()
|
||||||
|
for sourceValue in sourceArray {
|
||||||
|
switch Decoders.decode(clazz: T.self, source: sourceValue, instance: nil) {
|
||||||
|
case let .success(value):
|
||||||
|
values.append(value)
|
||||||
|
case let .failure(error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return .success(values)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decode<T, Key: Hashable>(clazz: [Key:T].Type, source: AnyObject) -> Decoded<[Key:T]> {
|
||||||
|
if let sourceDictionary = source as? [Key: AnyObject] {
|
||||||
|
var dictionary = [Key:T]()
|
||||||
|
for (key, value) in sourceDictionary {
|
||||||
|
switch Decoders.decode(clazz: T.self, source: value, instance: nil) {
|
||||||
|
case let .success(value):
|
||||||
|
dictionary[key] = value
|
||||||
|
case let .failure(error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return .success(dictionary)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T: RawRepresentable>(clazz: T.Type, source: AnyObject?) -> Decoded<T?> {
|
||||||
|
guard !(source is NSNull), source != nil else { return .success(nil) }
|
||||||
|
if let value = source as? T.RawValue {
|
||||||
|
if let enumValue = T.init(rawValue: value) {
|
||||||
|
return .success(enumValue)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "A value from the enumeration \(T.self)", actual: "\(value)"))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "\(T.RawValue.self) matching a case from the enumeration \(T.self)", actual: String(describing: type(of: source))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded<T> {
|
||||||
|
initialize()
|
||||||
|
if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type {
|
||||||
|
return .success(value)
|
||||||
|
}
|
||||||
|
if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type {
|
||||||
|
return .success(value)
|
||||||
|
}
|
||||||
|
if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type {
|
||||||
|
return .success(value)
|
||||||
|
}
|
||||||
|
if let value = source as? T {
|
||||||
|
return .success(value)
|
||||||
|
}
|
||||||
|
if let intermediate = source as? String, let value = Data(base64Encoded: intermediate) as? T {
|
||||||
|
return .success(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
let key = "\(T.self)"
|
||||||
|
if let decoder = decoders[key], let value = decoder(source, instance) as? Decoded<T> {
|
||||||
|
return value
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Convert a Decoded so that its value is optional. DO WE STILL NEED THIS?
|
||||||
|
static func toOptional<T>(decoded: Decoded<T>) -> Decoded<T?> {
|
||||||
|
return .success(decoded.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T>(clazz: T.Type, source: AnyObject?) -> Decoded<T?> {
|
||||||
|
if let source = source, !(source is NSNull) {
|
||||||
|
switch Decoders.decode(clazz: clazz, source: source, instance: nil) {
|
||||||
|
case let .success(value): return .success(value)
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .success(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T>(clazz: [T].Type, source: AnyObject?) -> Decoded<[T]?> {
|
||||||
|
if let source = source as? [AnyObject] {
|
||||||
|
var values = [T]()
|
||||||
|
for sourceValue in source {
|
||||||
|
switch Decoders.decode(clazz: T.self, source: sourceValue, instance: nil) {
|
||||||
|
case let .success(value): values.append(value)
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return .success(values)
|
||||||
|
} else {
|
||||||
|
return .success(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T, Key: Hashable>(clazz: [Key:T].Type, source: AnyObject?) -> Decoded<[Key:T]?> {
|
||||||
|
if let sourceDictionary = source as? [Key: AnyObject] {
|
||||||
|
var dictionary = [Key:T]()
|
||||||
|
for (key, value) in sourceDictionary {
|
||||||
|
switch Decoders.decode(clazz: T.self, source: value, instance: nil) {
|
||||||
|
case let .success(value): dictionary[key] = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return .success(dictionary)
|
||||||
|
} else {
|
||||||
|
return .success(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T: RawRepresentable, U: AnyObject where T.RawValue == U>(clazz: T, source: AnyObject) -> Decoded<T?> {
|
||||||
|
if let value = source as? U {
|
||||||
|
if let enumValue = T.init(rawValue: value) {
|
||||||
|
return .success(enumValue)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "A value from the enumeration \(T.self)", actual: "\(value)"))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "String", actual: String(describing: type(of: source))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static var __once: () = {
|
||||||
|
let formatters = [
|
||||||
|
"yyyy-MM-dd",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ss.SSS",
|
||||||
|
"yyyy-MM-dd HH:mm:ss"
|
||||||
|
].map { (format: String) -> DateFormatter in
|
||||||
|
let formatter = DateFormatter()
|
||||||
|
formatter.dateFormat = format
|
||||||
|
return formatter
|
||||||
|
}
|
||||||
|
// Decoder for Date
|
||||||
|
Decoders.addDecoder(clazz: Date.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Date> in
|
||||||
|
if let sourceString = source as? String {
|
||||||
|
for formatter in formatters {
|
||||||
|
if let date = formatter.date(from: sourceString) {
|
||||||
|
return .success(date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let sourceInt = source as? Int {
|
||||||
|
// treat as a java date
|
||||||
|
return .success(Date(timeIntervalSince1970: Double(sourceInt / 1000) ))
|
||||||
|
}
|
||||||
|
if source is String || source is Int {
|
||||||
|
return .failure(.parseError(message: "Could not decode date"))
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "String or Int", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decoder for ISOFullDate
|
||||||
|
Decoders.addDecoder(clazz: ISOFullDate.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ISOFullDate> in
|
||||||
|
if let string = source as? String,
|
||||||
|
let isoDate = ISOFullDate.from(string: string) {
|
||||||
|
return .success(isoDate)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "ISO date", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decoder for AdditionalPropertiesClass
|
||||||
|
Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<AdditionalPropertiesClass> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = AdditionalPropertiesClass()
|
||||||
|
switch Decoders.decodeOptional(clazz: [String:String].self, source: sourceDictionary["map_property"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.mapProperty = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: [String:[String:String]].self, source: sourceDictionary["map_of_map_property"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.mapOfMapProperty = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "AdditionalPropertiesClass", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Animal
|
||||||
|
Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Animal> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
// Check discriminator to support inheritance
|
||||||
|
if let discriminator = sourceDictionary["className"] as? String, instance == nil && discriminator != "Animal"{
|
||||||
|
return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source)
|
||||||
|
}
|
||||||
|
guard let classNameSource = sourceDictionary["className"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "className"))
|
||||||
|
}
|
||||||
|
guard let className = Decoders.decode(clazz: String.self.self, source: classNameSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "Animal", actual: "\(classNameSource)"))
|
||||||
|
}
|
||||||
|
let result = Animal(className: className)
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.color = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Animal", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for ApiResponse
|
||||||
|
Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ApiResponse> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = ApiResponse()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.code = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.type = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.message = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "ApiResponse", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for ArrayOfArrayOfNumberOnly
|
||||||
|
Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ArrayOfArrayOfNumberOnly> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = ArrayOfArrayOfNumberOnly()
|
||||||
|
switch Decoders.decodeOptional(clazz: [[Double]].self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.arrayArrayNumber = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "ArrayOfArrayOfNumberOnly", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for ArrayOfNumberOnly
|
||||||
|
Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ArrayOfNumberOnly> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = ArrayOfNumberOnly()
|
||||||
|
switch Decoders.decodeOptional(clazz: [Double].self, source: sourceDictionary["ArrayNumber"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.arrayNumber = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "ArrayOfNumberOnly", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for ArrayTest
|
||||||
|
Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ArrayTest> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = ArrayTest()
|
||||||
|
switch Decoders.decodeOptional(clazz: [String].self, source: sourceDictionary["array_of_string"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.arrayOfString = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: [[Int64]].self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.arrayArrayOfInteger = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: [[ReadOnlyFirst]].self, source: sourceDictionary["array_array_of_model"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.arrayArrayOfModel = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "ArrayTest", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Capitalization
|
||||||
|
Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Capitalization> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = Capitalization()
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.smallCamel = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.capitalCamel = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.smallSnake = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.capitalSnake = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.sCAETHFlowPoints = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.ATT_NAME = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Capitalization", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Category
|
||||||
|
Decoders.addDecoder(clazz: Category.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Category> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = Category()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.id = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.name = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Category", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for ClassModel
|
||||||
|
Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ClassModel> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = ClassModel()
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) {
|
||||||
|
case let .success(value): instance._class = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "ClassModel", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Client
|
||||||
|
Decoders.addDecoder(clazz: Client.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Client> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = Client()
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.client = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Client", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for EnumArrays
|
||||||
|
Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<EnumArrays> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = EnumArrays()
|
||||||
|
switch Decoders.decodeOptional(clazz: EnumArrays.JustSymbol.self, source: sourceDictionary["just_symbol"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.justSymbol = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Array<EnumArrays.ArrayEnum>.self, source: sourceDictionary["array_enum"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.arrayEnum = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "EnumArrays", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for EnumClass
|
||||||
|
Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<EnumClass> in
|
||||||
|
//TODO: I don't think we need this anymore
|
||||||
|
return Decoders.decode(clazz: EnumClass.self, source: source, instance: instance)
|
||||||
|
}
|
||||||
|
// Decoder for EnumTest
|
||||||
|
Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<EnumTest> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = EnumTest()
|
||||||
|
switch Decoders.decodeOptional(clazz: EnumTest.EnumString.self, source: sourceDictionary["enum_string"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.enumString = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: EnumTest.EnumInteger.self, source: sourceDictionary["enum_integer"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.enumInteger = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: EnumTest.EnumNumber.self, source: sourceDictionary["enum_number"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.enumNumber = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.outerEnum = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "EnumTest", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for FormatTest
|
||||||
|
Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<FormatTest> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
guard let numberSource = sourceDictionary["number"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "number"))
|
||||||
|
}
|
||||||
|
guard let number = Decoders.decode(clazz: Double.self.self, source: numberSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "FormatTest", actual: "\(numberSource)"))
|
||||||
|
}
|
||||||
|
guard let byteSource = sourceDictionary["byte"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "byte"))
|
||||||
|
}
|
||||||
|
guard let byte = Decoders.decode(clazz: Data.self.self, source: byteSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "FormatTest", actual: "\(byteSource)"))
|
||||||
|
}
|
||||||
|
guard let dateSource = sourceDictionary["date"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "date"))
|
||||||
|
}
|
||||||
|
guard let date = Decoders.decode(clazz: ISOFullDate.self.self, source: dateSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "FormatTest", actual: "\(dateSource)"))
|
||||||
|
}
|
||||||
|
guard let passwordSource = sourceDictionary["password"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "password"))
|
||||||
|
}
|
||||||
|
guard let password = Decoders.decode(clazz: String.self.self, source: passwordSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "FormatTest", actual: "\(passwordSource)"))
|
||||||
|
}
|
||||||
|
let result = FormatTest(number: number, byte: byte, date: date, password: password)
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.integer = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.int32 = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.int64 = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.float = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.double = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.string = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.binary = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.dateTime = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.uuid = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "FormatTest", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for HasOnlyReadOnly
|
||||||
|
Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<HasOnlyReadOnly> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = HasOnlyReadOnly()
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.bar = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.foo = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "HasOnlyReadOnly", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for List
|
||||||
|
Decoders.addDecoder(clazz: List.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<List> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = List()
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) {
|
||||||
|
case let .success(value): instance._123List = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "List", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for MapTest
|
||||||
|
Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<MapTest> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = MapTest()
|
||||||
|
switch Decoders.decodeOptional(clazz: [String:[String:String]].self, source: sourceDictionary["map_map_of_string"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.mapMapOfString = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: MapTest.MapOfEnumString.self, source: sourceDictionary["map_of_enum_string"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.mapOfEnumString = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "MapTest", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for MixedPropertiesAndAdditionalPropertiesClass
|
||||||
|
Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<MixedPropertiesAndAdditionalPropertiesClass> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = MixedPropertiesAndAdditionalPropertiesClass()
|
||||||
|
switch Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.uuid = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.dateTime = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: [String:Animal].self, source: sourceDictionary["map"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.map = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "MixedPropertiesAndAdditionalPropertiesClass", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Model200Response
|
||||||
|
Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Model200Response> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = Model200Response()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.name = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) {
|
||||||
|
case let .success(value): instance._class = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Model200Response", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Name
|
||||||
|
Decoders.addDecoder(clazz: Name.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Name> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
guard let nameSource = sourceDictionary["name"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "name"))
|
||||||
|
}
|
||||||
|
guard let name = Decoders.decode(clazz: Int32.self.self, source: nameSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "Name", actual: "\(nameSource)"))
|
||||||
|
}
|
||||||
|
let result = Name(name: name)
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.snakeCase = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.property = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) {
|
||||||
|
case let .success(value): instance._123Number = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Name", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for NumberOnly
|
||||||
|
Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<NumberOnly> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = NumberOnly()
|
||||||
|
switch Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.justNumber = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "NumberOnly", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Order
|
||||||
|
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Order> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = Order()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.id = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.petId = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.quantity = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.shipDate = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Order.Status.self, source: sourceDictionary["status"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.status = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.complete = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Order", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for OuterBoolean
|
||||||
|
Decoders.addDecoder(clazz: OuterBoolean.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterBoolean> in
|
||||||
|
if let source = source as? Bool {
|
||||||
|
return .success(source)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Typealias OuterBoolean", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for OuterComposite
|
||||||
|
Decoders.addDecoder(clazz: OuterComposite.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterComposite> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = OuterComposite()
|
||||||
|
switch Decoders.decodeOptional(clazz: OuterNumber.self, source: sourceDictionary["my_number"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.myNumber = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: OuterString.self, source: sourceDictionary["my_string"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.myString = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: OuterBoolean.self, source: sourceDictionary["my_boolean"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.myBoolean = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "OuterComposite", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for OuterEnum
|
||||||
|
Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterEnum> in
|
||||||
|
//TODO: I don't think we need this anymore
|
||||||
|
return Decoders.decode(clazz: OuterEnum.self, source: source, instance: instance)
|
||||||
|
}
|
||||||
|
// Decoder for OuterNumber
|
||||||
|
Decoders.addDecoder(clazz: OuterNumber.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterNumber> in
|
||||||
|
if let source = source as? Double {
|
||||||
|
return .success(source)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Typealias OuterNumber", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for OuterString
|
||||||
|
Decoders.addDecoder(clazz: OuterString.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterString> in
|
||||||
|
if let source = source as? String {
|
||||||
|
return .success(source)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Typealias OuterString", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Pet
|
||||||
|
Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Pet> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
guard let nameSource = sourceDictionary["name"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "name"))
|
||||||
|
}
|
||||||
|
guard let name = Decoders.decode(clazz: String.self.self, source: nameSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "Pet", actual: "\(nameSource)"))
|
||||||
|
}
|
||||||
|
guard let photoUrlsSource = sourceDictionary["photoUrls"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "photoUrls"))
|
||||||
|
}
|
||||||
|
guard let photoUrls = Decoders.decode(clazz: [String].self.self, source: photoUrlsSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "Pet", actual: "\(photoUrlsSource)"))
|
||||||
|
}
|
||||||
|
let result = Pet(name: name, photoUrls: photoUrls)
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.id = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.category = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: [Tag].self, source: sourceDictionary["tags"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.tags = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Pet.Status.self, source: sourceDictionary["status"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.status = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Pet", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for ReadOnlyFirst
|
||||||
|
Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ReadOnlyFirst> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = ReadOnlyFirst()
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.bar = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.baz = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "ReadOnlyFirst", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Return
|
||||||
|
Decoders.addDecoder(clazz: Return.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Return> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = Return()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) {
|
||||||
|
case let .success(value): instance._return = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Return", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for SpecialModelName
|
||||||
|
Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<SpecialModelName> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = SpecialModelName()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.specialPropertyName = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "SpecialModelName", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Tag
|
||||||
|
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Tag> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = Tag()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.id = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.name = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Tag", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for User
|
||||||
|
Decoders.addDecoder(clazz: User.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<User> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
let result = User()
|
||||||
|
switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.id = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.username = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.firstName = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.lastName = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.email = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.password = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.phone = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.userStatus = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "User", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Cat
|
||||||
|
Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Cat> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
guard let classNameSource = sourceDictionary["className"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "className"))
|
||||||
|
}
|
||||||
|
guard let className = Decoders.decode(clazz: String.self.self, source: classNameSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "Cat", actual: "\(classNameSource)"))
|
||||||
|
}
|
||||||
|
let result = Cat(className: className)
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.color = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.declawed = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Cat", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Decoder for Dog
|
||||||
|
Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Dog> in
|
||||||
|
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||||
|
guard let classNameSource = sourceDictionary["className"] as AnyObject? else {
|
||||||
|
return .failure(.missingKey(key: "className"))
|
||||||
|
}
|
||||||
|
guard let className = Decoders.decode(clazz: String.self.self, source: classNameSource).value else {
|
||||||
|
return .failure(.typeMismatch(expected: "Dog", actual: "\(classNameSource)"))
|
||||||
|
}
|
||||||
|
let result = Dog(className: className)
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.color = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) {
|
||||||
|
case let .success(value): instance.breed = value
|
||||||
|
case let .failure(error): return .failure(error)
|
||||||
|
}
|
||||||
|
return .success(result)
|
||||||
|
} else {
|
||||||
|
return .failure(.typeMismatch(expected: "Dog", actual: "\(source)"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
static fileprivate func initialize() {
|
||||||
|
_ = Decoders.__once
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// AdditionalPropertiesClass.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class AdditionalPropertiesClass: JSONEncodable {
|
||||||
|
|
||||||
|
public var mapProperty: [String:String]?
|
||||||
|
public var mapOfMapProperty: [String:[String:String]]?
|
||||||
|
|
||||||
|
|
||||||
|
public init(mapProperty: [String:String]?=nil, mapOfMapProperty: [String:[String:String]]?=nil) {
|
||||||
|
self.mapProperty = mapProperty
|
||||||
|
self.mapOfMapProperty = mapOfMapProperty
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["map_property"] = self.mapProperty?.encodeToJSON()
|
||||||
|
nillableDictionary["map_of_map_property"] = self.mapOfMapProperty?.encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// Animal.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Animal: JSONEncodable {
|
||||||
|
|
||||||
|
public var className: String
|
||||||
|
public var color: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(className: String, color: String?=nil) {
|
||||||
|
self.className = className
|
||||||
|
self.color = color
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["className"] = self.className
|
||||||
|
nillableDictionary["color"] = self.color
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// AnimalFarm.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public typealias AnimalFarm = [Animal]
|
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// ApiResponse.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class ApiResponse: JSONEncodable {
|
||||||
|
|
||||||
|
public var code: Int32?
|
||||||
|
public var type: String?
|
||||||
|
public var message: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(code: Int32?=nil, type: String?=nil, message: String?=nil) {
|
||||||
|
self.code = code
|
||||||
|
self.type = type
|
||||||
|
self.message = message
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["code"] = self.code?.encodeToJSON()
|
||||||
|
nillableDictionary["type"] = self.type
|
||||||
|
nillableDictionary["message"] = self.message
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// ArrayOfArrayOfNumberOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class ArrayOfArrayOfNumberOnly: JSONEncodable {
|
||||||
|
|
||||||
|
public var arrayArrayNumber: [[Double]]?
|
||||||
|
|
||||||
|
|
||||||
|
public init(arrayArrayNumber: [[Double]]?=nil) {
|
||||||
|
self.arrayArrayNumber = arrayArrayNumber
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["ArrayArrayNumber"] = self.arrayArrayNumber?.encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// ArrayOfNumberOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class ArrayOfNumberOnly: JSONEncodable {
|
||||||
|
|
||||||
|
public var arrayNumber: [Double]?
|
||||||
|
|
||||||
|
|
||||||
|
public init(arrayNumber: [Double]?=nil) {
|
||||||
|
self.arrayNumber = arrayNumber
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["ArrayNumber"] = self.arrayNumber?.encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// ArrayTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class ArrayTest: JSONEncodable {
|
||||||
|
|
||||||
|
public var arrayOfString: [String]?
|
||||||
|
public var arrayArrayOfInteger: [[Int64]]?
|
||||||
|
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
|
||||||
|
|
||||||
|
|
||||||
|
public init(arrayOfString: [String]?=nil, arrayArrayOfInteger: [[Int64]]?=nil, arrayArrayOfModel: [[ReadOnlyFirst]]?=nil) {
|
||||||
|
self.arrayOfString = arrayOfString
|
||||||
|
self.arrayArrayOfInteger = arrayArrayOfInteger
|
||||||
|
self.arrayArrayOfModel = arrayArrayOfModel
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["array_of_string"] = self.arrayOfString?.encodeToJSON()
|
||||||
|
nillableDictionary["array_array_of_integer"] = self.arrayArrayOfInteger?.encodeToJSON()
|
||||||
|
nillableDictionary["array_array_of_model"] = self.arrayArrayOfModel?.encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// Capitalization.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Capitalization: JSONEncodable {
|
||||||
|
|
||||||
|
public var smallCamel: String?
|
||||||
|
public var capitalCamel: String?
|
||||||
|
public var smallSnake: String?
|
||||||
|
public var capitalSnake: String?
|
||||||
|
public var sCAETHFlowPoints: String?
|
||||||
|
/** Name of the pet */
|
||||||
|
public var ATT_NAME: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(smallCamel: String?=nil, capitalCamel: String?=nil, smallSnake: String?=nil, capitalSnake: String?=nil, sCAETHFlowPoints: String?=nil, ATT_NAME: String?=nil) {
|
||||||
|
self.smallCamel = smallCamel
|
||||||
|
self.capitalCamel = capitalCamel
|
||||||
|
self.smallSnake = smallSnake
|
||||||
|
self.capitalSnake = capitalSnake
|
||||||
|
self.sCAETHFlowPoints = sCAETHFlowPoints
|
||||||
|
self.ATT_NAME = ATT_NAME
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["smallCamel"] = self.smallCamel
|
||||||
|
nillableDictionary["CapitalCamel"] = self.capitalCamel
|
||||||
|
nillableDictionary["small_Snake"] = self.smallSnake
|
||||||
|
nillableDictionary["Capital_Snake"] = self.capitalSnake
|
||||||
|
nillableDictionary["SCA_ETH_Flow_Points"] = self.sCAETHFlowPoints
|
||||||
|
nillableDictionary["ATT_NAME"] = self.ATT_NAME
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Cat.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Cat: Animal {
|
||||||
|
|
||||||
|
public var declawed: Bool?
|
||||||
|
|
||||||
|
|
||||||
|
public init(className: String, color: String?=nil, declawed: Bool?=nil) {
|
||||||
|
self.declawed = declawed
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
override open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]()
|
||||||
|
nillableDictionary["declawed"] = self.declawed
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// Category.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Category: JSONEncodable {
|
||||||
|
|
||||||
|
public var id: Int64?
|
||||||
|
public var name: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(id: Int64?=nil, name: String?=nil) {
|
||||||
|
self.id = id
|
||||||
|
self.name = name
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
|
nillableDictionary["name"] = self.name
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// ClassModel.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/** Model for testing model with \"_class\" property */
|
||||||
|
open class ClassModel: JSONEncodable {
|
||||||
|
|
||||||
|
public var _class: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(_class: String?=nil) {
|
||||||
|
self._class = _class
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["_class"] = self._class
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Client.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Client: JSONEncodable {
|
||||||
|
|
||||||
|
public var client: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(client: String?=nil) {
|
||||||
|
self.client = client
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["client"] = self.client
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Dog.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Dog: Animal {
|
||||||
|
|
||||||
|
public var breed: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(className: String, color: String?=nil, breed: String?=nil) {
|
||||||
|
self.breed = breed
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
override open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = super.encodeToJSON() as? [String:Any?] ?? [String:Any?]()
|
||||||
|
nillableDictionary["breed"] = self.breed
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// EnumArrays.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class EnumArrays: JSONEncodable {
|
||||||
|
|
||||||
|
public enum JustSymbol: String {
|
||||||
|
case greaterThanOrEqualTo = ">="
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
public enum ArrayEnum: String {
|
||||||
|
case fish = "fish"
|
||||||
|
case crab = "crab"
|
||||||
|
}
|
||||||
|
public var justSymbol: JustSymbol?
|
||||||
|
public var arrayEnum: [ArrayEnum]?
|
||||||
|
|
||||||
|
|
||||||
|
public init(justSymbol: JustSymbol?=nil, arrayEnum: [ArrayEnum]?=nil) {
|
||||||
|
self.justSymbol = justSymbol
|
||||||
|
self.arrayEnum = arrayEnum
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["just_symbol"] = self.justSymbol?.rawValue
|
||||||
|
nillableDictionary["array_enum"] = self.arrayEnum?.map({$0.rawValue}).encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// EnumClass.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public enum EnumClass: String {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
|
||||||
|
func encodeToJSON() -> Any { return self.rawValue }
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
//
|
||||||
|
// EnumTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class EnumTest: JSONEncodable {
|
||||||
|
|
||||||
|
public enum EnumString: String {
|
||||||
|
case upper = "UPPER"
|
||||||
|
case lower = "lower"
|
||||||
|
case empty = ""
|
||||||
|
}
|
||||||
|
public enum EnumInteger: Int32 {
|
||||||
|
case _1 = 1
|
||||||
|
case numberminus1 = -1
|
||||||
|
}
|
||||||
|
public enum EnumNumber: Double {
|
||||||
|
case _11 = 1.1
|
||||||
|
case numberminus12 = -1.2
|
||||||
|
}
|
||||||
|
public var enumString: EnumString?
|
||||||
|
public var enumInteger: EnumInteger?
|
||||||
|
public var enumNumber: EnumNumber?
|
||||||
|
public var outerEnum: OuterEnum?
|
||||||
|
|
||||||
|
|
||||||
|
public init(enumString: EnumString?=nil, enumInteger: EnumInteger?=nil, enumNumber: EnumNumber?=nil, outerEnum: OuterEnum?=nil) {
|
||||||
|
self.enumString = enumString
|
||||||
|
self.enumInteger = enumInteger
|
||||||
|
self.enumNumber = enumNumber
|
||||||
|
self.outerEnum = outerEnum
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["enum_string"] = self.enumString?.rawValue
|
||||||
|
nillableDictionary["enum_integer"] = self.enumInteger?.rawValue
|
||||||
|
nillableDictionary["enum_number"] = self.enumNumber?.rawValue
|
||||||
|
nillableDictionary["outerEnum"] = self.outerEnum?.encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// FormatTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class FormatTest: JSONEncodable {
|
||||||
|
|
||||||
|
public var integer: Int32?
|
||||||
|
public var int32: Int32?
|
||||||
|
public var int64: Int64?
|
||||||
|
public var number: Double
|
||||||
|
public var float: Float?
|
||||||
|
public var double: Double?
|
||||||
|
public var string: String?
|
||||||
|
public var byte: Data
|
||||||
|
public var binary: Data?
|
||||||
|
public var date: ISOFullDate
|
||||||
|
public var dateTime: Date?
|
||||||
|
public var uuid: UUID?
|
||||||
|
public var password: String
|
||||||
|
|
||||||
|
|
||||||
|
public init(integer: Int32?=nil, int32: Int32?=nil, int64: Int64?=nil, number: Double, float: Float?=nil, double: Double?=nil, string: String?=nil, byte: Data, binary: Data?=nil, date: ISOFullDate, dateTime: Date?=nil, uuid: UUID?=nil, password: String) {
|
||||||
|
self.integer = integer
|
||||||
|
self.int32 = int32
|
||||||
|
self.int64 = int64
|
||||||
|
self.number = number
|
||||||
|
self.float = float
|
||||||
|
self.double = double
|
||||||
|
self.string = string
|
||||||
|
self.byte = byte
|
||||||
|
self.binary = binary
|
||||||
|
self.date = date
|
||||||
|
self.dateTime = dateTime
|
||||||
|
self.uuid = uuid
|
||||||
|
self.password = password
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["integer"] = self.integer?.encodeToJSON()
|
||||||
|
nillableDictionary["int32"] = self.int32?.encodeToJSON()
|
||||||
|
nillableDictionary["int64"] = self.int64?.encodeToJSON()
|
||||||
|
nillableDictionary["number"] = self.number
|
||||||
|
nillableDictionary["float"] = self.float
|
||||||
|
nillableDictionary["double"] = self.double
|
||||||
|
nillableDictionary["string"] = self.string
|
||||||
|
nillableDictionary["byte"] = self.byte.encodeToJSON()
|
||||||
|
nillableDictionary["binary"] = self.binary?.encodeToJSON()
|
||||||
|
nillableDictionary["date"] = self.date.encodeToJSON()
|
||||||
|
nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON()
|
||||||
|
nillableDictionary["uuid"] = self.uuid?.encodeToJSON()
|
||||||
|
nillableDictionary["password"] = self.password
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// HasOnlyReadOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class HasOnlyReadOnly: JSONEncodable {
|
||||||
|
|
||||||
|
public var bar: String?
|
||||||
|
public var foo: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(bar: String?=nil, foo: String?=nil) {
|
||||||
|
self.bar = bar
|
||||||
|
self.foo = foo
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["bar"] = self.bar
|
||||||
|
nillableDictionary["foo"] = self.foo
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// List.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class List: JSONEncodable {
|
||||||
|
|
||||||
|
public var _123List: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(_123List: String?=nil) {
|
||||||
|
self._123List = _123List
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["123-list"] = self._123List
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// MapTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class MapTest: JSONEncodable {
|
||||||
|
|
||||||
|
public enum MapOfEnumString: String {
|
||||||
|
case upper = "UPPER"
|
||||||
|
case lower = "lower"
|
||||||
|
}
|
||||||
|
public var mapMapOfString: [String:[String:String]]?
|
||||||
|
public var mapOfEnumString: [String:String]?
|
||||||
|
|
||||||
|
|
||||||
|
public init(mapMapOfString: [String:[String:String]]?=nil, mapOfEnumString: [String:String]?=nil) {
|
||||||
|
self.mapMapOfString = mapMapOfString
|
||||||
|
self.mapOfEnumString = mapOfEnumString
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["map_map_of_string"] = self.mapMapOfString?.encodeToJSON()//TODO: handle enum map scenario
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// MixedPropertiesAndAdditionalPropertiesClass.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class MixedPropertiesAndAdditionalPropertiesClass: JSONEncodable {
|
||||||
|
|
||||||
|
public var uuid: UUID?
|
||||||
|
public var dateTime: Date?
|
||||||
|
public var map: [String:Animal]?
|
||||||
|
|
||||||
|
|
||||||
|
public init(uuid: UUID?=nil, dateTime: Date?=nil, map: [String:Animal]?=nil) {
|
||||||
|
self.uuid = uuid
|
||||||
|
self.dateTime = dateTime
|
||||||
|
self.map = map
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["uuid"] = self.uuid?.encodeToJSON()
|
||||||
|
nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON()
|
||||||
|
nillableDictionary["map"] = self.map?.encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// Model200Response.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/** Model for testing model name starting with number */
|
||||||
|
open class Model200Response: JSONEncodable {
|
||||||
|
|
||||||
|
public var name: Int32?
|
||||||
|
public var _class: String?
|
||||||
|
|
||||||
|
|
||||||
|
public init(name: Int32?=nil, _class: String?=nil) {
|
||||||
|
self.name = name
|
||||||
|
self._class = _class
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["name"] = self.name?.encodeToJSON()
|
||||||
|
nillableDictionary["class"] = self._class
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// Name.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/** Model for testing model name same as property name */
|
||||||
|
open class Name: JSONEncodable {
|
||||||
|
|
||||||
|
public var name: Int32
|
||||||
|
public var snakeCase: Int32?
|
||||||
|
public var property: String?
|
||||||
|
public var _123Number: Int32?
|
||||||
|
|
||||||
|
|
||||||
|
public init(name: Int32, snakeCase: Int32?=nil, property: String?=nil, _123Number: Int32?=nil) {
|
||||||
|
self.name = name
|
||||||
|
self.snakeCase = snakeCase
|
||||||
|
self.property = property
|
||||||
|
self._123Number = _123Number
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["name"] = self.name.encodeToJSON()
|
||||||
|
nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON()
|
||||||
|
nillableDictionary["property"] = self.property
|
||||||
|
nillableDictionary["123Number"] = self._123Number?.encodeToJSON()
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// NumberOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class NumberOnly: JSONEncodable {
|
||||||
|
|
||||||
|
public var justNumber: Double?
|
||||||
|
|
||||||
|
|
||||||
|
public init(justNumber: Double?=nil) {
|
||||||
|
self.justNumber = justNumber
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["JustNumber"] = self.justNumber
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// Order.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Order: JSONEncodable {
|
||||||
|
|
||||||
|
public enum Status: String {
|
||||||
|
case placed = "placed"
|
||||||
|
case approved = "approved"
|
||||||
|
case delivered = "delivered"
|
||||||
|
}
|
||||||
|
public var id: Int64?
|
||||||
|
public var petId: Int64?
|
||||||
|
public var quantity: Int32?
|
||||||
|
public var shipDate: Date?
|
||||||
|
/** Order Status */
|
||||||
|
public var status: Status?
|
||||||
|
public var complete: Bool?
|
||||||
|
|
||||||
|
|
||||||
|
public init(id: Int64?=nil, petId: Int64?=nil, quantity: Int32?=nil, shipDate: Date?=nil, status: Status?=nil, complete: Bool?=nil) {
|
||||||
|
self.id = id
|
||||||
|
self.petId = petId
|
||||||
|
self.quantity = quantity
|
||||||
|
self.shipDate = shipDate
|
||||||
|
self.status = status
|
||||||
|
self.complete = complete
|
||||||
|
}
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
open func encodeToJSON() -> Any {
|
||||||
|
var nillableDictionary = [String:Any?]()
|
||||||
|
nillableDictionary["id"] = self.id?.encodeToJSON()
|
||||||
|
nillableDictionary["petId"] = self.petId?.encodeToJSON()
|
||||||
|
nillableDictionary["quantity"] = self.quantity?.encodeToJSON()
|
||||||
|
nillableDictionary["shipDate"] = self.shipDate?.encodeToJSON()
|
||||||
|
nillableDictionary["status"] = self.status?.rawValue
|
||||||
|
nillableDictionary["complete"] = self.complete
|
||||||
|
|
||||||
|
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// OuterBoolean.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public typealias OuterBoolean = Bool
|
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