mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
Typescript fetch fork (#569)
* added my fork from https://github.com/Place1/swagger-codegen-typescript-browser * ran bin/typescript-fetch-petstore-all.sh * use FormData.append rather than .set for IE11 compat * reverted change to licenseInfo.mustache * reverted some comments * added package.json and tsconfig.json back to the generator * added support for blob (application/octet-stream) responses * models and apis are now in folders * added support for modelPropertyNaming based on the spec * bug fix * updated samples * Restore pom.xml for typescript project * Restore samples/client/petstore/typescript-fetch/tests/default/package.json ≈ * added support for response type Date conversion * updated samples * Rework pom in "samples.ci" * Restore "samples/client/petstore/typescript-fetch/tests/default" * updated configuration class to use property getters to allow clients to implement configuration values as getters * added {{datatype}}ToJSON functions to handle serialization and naming conversions * fixed missing import * fixed compilation error. updated samples * 1 character change to get CI to run again * updated samples * added support for array type request body * updated tests * support for optional request bodies * updated models json converters to handle undefined inputs (to simplify usage in optional contexts like optional request bodies) * updated samples * updated tests * changed to typescript version 2.4 * updated samples * support for optional properties being null, undefined or omitted * updated samples * bug fix * bug fix * updated samples * ran npm install in test project * patch to get tests running * added support for retrieving raw response. added support for binary request bodies. added support for blob data type for files/binary.
This commit is contained in:
parent
736e8348b6
commit
334415dec2
@ -0,0 +1,26 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>TypeScriptAngularBuildPestoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>TS Fetch Default Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,59 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>TypeScriptAngularBuildES6PestoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>TS Fetch ES6 Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>npm-install</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,73 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>TypeScriptAngularBuildWithNPMVersionPestoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>TS Fetch Petstore Client (with npm)</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>npm-install</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-build</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>run</argument>
|
||||||
|
<argument>build</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,59 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>TypeScriptFetchPestoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>TS Fetch Petstore Test Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>npm-install</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1 @@
|
|||||||
|
c2fcc2ae9693a8e8d02b25e286844aad88188fcb
|
Binary file not shown.
@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
|
|||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-target-es6.json -o samples/client/petstore/typescript-fetch/builds/es6-target $@"
|
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-target-es6.json -o samples/client/petstore/typescript-fetch/builds/es6-target $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
cp CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml samples/client/petstore/typescript-fetch/builds/es6-target/pom.xml
|
||||||
|
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml
|
@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
|
|||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-with-npm-version.json -o samples/client/petstore/typescript-fetch/builds/with-npm-version $@"
|
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -c bin/typescript-fetch-petstore-with-npm-version.json -o samples/client/petstore/typescript-fetch/builds/with-npm-version $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
cp CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml samples/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml
|
||||||
|
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml
|
@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
|
|||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -o samples/client/petstore/typescript-fetch/builds/default $@"
|
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -o samples/client/petstore/typescript-fetch/builds/default $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
cp CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml samples/client/petstore/typescript-fetch/builds/default/pom.xml
|
||||||
|
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml
|
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.invoke
|
||||||
|
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension
|
||||||
|
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension
|
||||||
|
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension
|
||||||
|
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
|
||||||
|
import org.openapitools.generator.gradle.plugin.tasks.GeneratorsTask
|
||||||
|
import org.openapitools.generator.gradle.plugin.tasks.MetaTask
|
||||||
|
import org.openapitools.generator.gradle.plugin.tasks.ValidateTask
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A plugin providing common Open API Generator use cases.
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
@Suppress("unused")
|
||||||
|
class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.run {
|
||||||
|
val meta = extensions.create(
|
||||||
|
"openApiMeta",
|
||||||
|
OpenApiGeneratorMetaExtension::class.java,
|
||||||
|
project
|
||||||
|
)
|
||||||
|
|
||||||
|
val validate = extensions.create(
|
||||||
|
"openApiValidate",
|
||||||
|
OpenApiGeneratorValidateExtension::class.java,
|
||||||
|
project
|
||||||
|
)
|
||||||
|
|
||||||
|
val generate = extensions.create(
|
||||||
|
"openApiGenerate",
|
||||||
|
OpenApiGeneratorGenerateExtension::class.java,
|
||||||
|
project
|
||||||
|
)
|
||||||
|
|
||||||
|
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
"openApiGenerators"(GeneratorsTask::class) {
|
||||||
|
group = pluginGroup
|
||||||
|
description = "Lists generators available via Open API Generators."
|
||||||
|
}
|
||||||
|
"openApiMeta"(MetaTask::class) {
|
||||||
|
group = pluginGroup
|
||||||
|
description = "Generates a new generator to be consumed via Open API Generator."
|
||||||
|
|
||||||
|
generatorName.set(meta.generatorName)
|
||||||
|
packageName.set(meta.packageName)
|
||||||
|
outputFolder.set(meta.outputFolder)
|
||||||
|
}
|
||||||
|
"openApiValidate"(ValidateTask::class) {
|
||||||
|
group = pluginGroup
|
||||||
|
description = "Validates an Open API 2.0 or 3.x specification document."
|
||||||
|
|
||||||
|
inputSpec.set(validate.inputSpec)
|
||||||
|
}
|
||||||
|
"openApiGenerate"(GenerateTask::class) {
|
||||||
|
group = pluginGroup
|
||||||
|
description = "Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents."
|
||||||
|
|
||||||
|
verbose.set(generate.verbose)
|
||||||
|
validateSpec.set(generate.validateSpec)
|
||||||
|
generatorName.set(generate.generatorName)
|
||||||
|
outputDir.set(generate.outputDir)
|
||||||
|
inputSpec.set(generate.inputSpec)
|
||||||
|
templateDir.set(generate.templateDir)
|
||||||
|
auth.set(generate.auth)
|
||||||
|
systemProperties.set(generate.systemProperties)
|
||||||
|
configFile.set(generate.configFile)
|
||||||
|
skipOverwrite.set(generate.skipOverwrite)
|
||||||
|
apiPackage.set(generate.apiPackage)
|
||||||
|
modelPackage.set(generate.modelPackage)
|
||||||
|
modelNamePrefix.set(generate.modelNamePrefix)
|
||||||
|
modelNameSuffix.set(generate.modelNameSuffix)
|
||||||
|
instantiationTypes.set(generate.instantiationTypes)
|
||||||
|
typeMappings.set(generate.typeMappings)
|
||||||
|
additionalProperties.set(generate.additionalProperties)
|
||||||
|
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
||||||
|
importMappings.set(generate.importMappings)
|
||||||
|
invokerPackage.set(generate.invokerPackage)
|
||||||
|
groupId.set(generate.groupId)
|
||||||
|
id.set(generate.id)
|
||||||
|
version.set(generate.version)
|
||||||
|
library.set(generate.library)
|
||||||
|
gitUserId.set(generate.gitUserId)
|
||||||
|
gitRepoId.set(generate.gitRepoId)
|
||||||
|
releaseNote.set(generate.releaseNote)
|
||||||
|
httpUserAgent.set(generate.httpUserAgent)
|
||||||
|
reservedWordsMappings.set(generate.reservedWordsMappings)
|
||||||
|
ignoreFileOverride.set(generate.ignoreFileOverride)
|
||||||
|
removeOperationIdPrefix.set(generate.removeOperationIdPrefix)
|
||||||
|
apiFilesConstrainedTo.set(generate.apiFilesConstrainedTo)
|
||||||
|
modelFilesConstrainedTo.set(generate.modelFilesConstrainedTo)
|
||||||
|
supportingFilesConstrainedTo.set(generate.supportingFilesConstrainedTo)
|
||||||
|
generateModelTests.set(generate.generateModelTests)
|
||||||
|
generateModelDocumentation.set(generate.generateModelDocumentation)
|
||||||
|
generateApiTests.set(generate.generateApiTests)
|
||||||
|
generateApiDocumentation.set(generate.generateApiDocumentation)
|
||||||
|
withXml.set(generate.withXml)
|
||||||
|
configOptions.set(generate.configOptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val pluginGroup = "OpenAPI Tools"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,286 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin.extensions
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.listProperty
|
||||||
|
import org.gradle.kotlin.dsl.property
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gradle project level extension object definition for the generate task
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The verbosity of generation
|
||||||
|
*/
|
||||||
|
val verbose = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not an input specification should be validated upon generation.
|
||||||
|
*/
|
||||||
|
val validateSpec = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the generator which will handle codegen. (see "openApiGenerators" task)
|
||||||
|
*/
|
||||||
|
val generatorName = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The output target directory into which code will be generated.
|
||||||
|
*/
|
||||||
|
val outputDir = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Open API 2.0/3.x specification location.
|
||||||
|
*/
|
||||||
|
val inputSpec = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template directory holding a custom template.
|
||||||
|
*/
|
||||||
|
val templateDir = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds authorization headers when fetching the OpenAPI definitions remotely.
|
||||||
|
* Pass in a URL-encoded string of name:header with a comma separating multiple values
|
||||||
|
*/
|
||||||
|
val auth = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets specified system properties.
|
||||||
|
*/
|
||||||
|
val systemProperties = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to json configuration file.
|
||||||
|
* File content should be in a json format { "optionKey":"optionValue", "optionKey1":"optionValue1"...}
|
||||||
|
* Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options.
|
||||||
|
*/
|
||||||
|
val configFile = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if the existing files should be overwritten during the generation.
|
||||||
|
*/
|
||||||
|
val skipOverwrite = project.objects.property<Boolean?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package for generated api classes
|
||||||
|
*/
|
||||||
|
val apiPackage = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package for generated models
|
||||||
|
*/
|
||||||
|
val modelPackage = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix that will be prepended to all model names. Default is the empty string.
|
||||||
|
*/
|
||||||
|
val modelNamePrefix = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suffix that will be appended to all model names. Default is the empty string.
|
||||||
|
*/
|
||||||
|
val modelNameSuffix = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets instantiation type mappings.
|
||||||
|
*/
|
||||||
|
val instantiationTypes = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets mappings between OpenAPI spec types and generated code types.
|
||||||
|
*/
|
||||||
|
val typeMappings = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets additional properties that can be referenced by the mustache templates.
|
||||||
|
*/
|
||||||
|
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||||
|
*/
|
||||||
|
val languageSpecificPrimitives = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies mappings between a given class and the import that should be used for that class.
|
||||||
|
*/
|
||||||
|
val importMappings = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Root package for generated code.
|
||||||
|
*/
|
||||||
|
val invokerPackage = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GroupId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
|
*/
|
||||||
|
val groupId = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ArtifactId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
|
*/
|
||||||
|
val id = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Artifact version in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
|
*/
|
||||||
|
val version = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference the library template (sub-template) of a generator.
|
||||||
|
*/
|
||||||
|
val library = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Git user ID, e.g. openapitools.
|
||||||
|
*/
|
||||||
|
val gitUserId = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Git repo ID, e.g. openapi-generator.
|
||||||
|
*/
|
||||||
|
val gitRepoId = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release note, default to 'Minor update'.
|
||||||
|
*/
|
||||||
|
val releaseNote = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}}/{language}'
|
||||||
|
*/
|
||||||
|
val httpUserAgent = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies how a reserved name should be escaped to. Otherwise, the default _<name> is used.
|
||||||
|
*/
|
||||||
|
val reservedWordsMappings = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
|
||||||
|
*/
|
||||||
|
val ignoreFileOverride = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove prefix of operationId, e.g. config_getId => getId
|
||||||
|
*/
|
||||||
|
val removeOperationIdPrefix = project.objects.property<Boolean?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines which API-related files should be generated. This allows you to create a subset of generated files (or none at all).
|
||||||
|
*
|
||||||
|
* NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results
|
||||||
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
val apiFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines which model-related files should be generated. This allows you to create a subset of generated files (or none at all).
|
||||||
|
*
|
||||||
|
* NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results
|
||||||
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
val modelFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines which supporting files should be generated. This allows you to create a subset of generated files (or none at all).
|
||||||
|
*
|
||||||
|
* Supporting files are those related to projects/frameworks which may be modified
|
||||||
|
* by consumers.
|
||||||
|
*
|
||||||
|
* NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results
|
||||||
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
val supportingFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not model-related _test_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL model-related _test_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
val generateModelTests = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not model-related _documentation_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL model-related _documentation_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
val generateModelDocumentation = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not api-related _test_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL api-related _test_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
val generateApiTests = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not api-related _documentation_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL api-related _documentation_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
val generateApiDocumentation = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A special-case setting which configures some generators with XML support. In some cases,
|
||||||
|
* this forces json OR xml, so the default here is false.
|
||||||
|
*/
|
||||||
|
val withXml = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of options specific to a generator.
|
||||||
|
*/
|
||||||
|
val configOptions = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
applyDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
fun applyDefaults(){
|
||||||
|
releaseNote.set("Minor update")
|
||||||
|
modelNamePrefix.set("")
|
||||||
|
modelNameSuffix.set("")
|
||||||
|
generateModelTests.set(true)
|
||||||
|
generateModelDocumentation.set(true)
|
||||||
|
generateApiTests.set(true)
|
||||||
|
generateApiDocumentation.set(true)
|
||||||
|
withXml.set(false)
|
||||||
|
configOptions.set(mapOf())
|
||||||
|
validateSpec.set(true)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin.extensions
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.property
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gradle project level extension object definition for the meta-generator task
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class OpenApiGeneratorMetaExtension(project: Project) {
|
||||||
|
/**
|
||||||
|
* The human-readable generator name of the newly created template generator.
|
||||||
|
*/
|
||||||
|
val generatorName = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The packageName generatorName to put the main class into (defaults to org.openapitools.codegen)
|
||||||
|
*/
|
||||||
|
val packageName = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to write the generated files (current dir by default).
|
||||||
|
*/
|
||||||
|
val outputFolder = project.objects.property<String>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
generatorName.set("default")
|
||||||
|
packageName.set("org.openapitools.codegen")
|
||||||
|
outputFolder.set("")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin.extensions
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.property
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gradle project level extension object definition for the generators task
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class OpenApiGeneratorValidateExtension(project: Project) {
|
||||||
|
/**
|
||||||
|
* The input specification to validate. Supports all formats supported by the Parser.
|
||||||
|
*/
|
||||||
|
val inputSpec = project.objects.property<String>()
|
||||||
|
}
|
@ -0,0 +1,554 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.GradleException
|
||||||
|
import org.gradle.api.provider.Property
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||||
|
import org.gradle.kotlin.dsl.listProperty
|
||||||
|
import org.gradle.kotlin.dsl.property
|
||||||
|
import org.openapitools.codegen.CodegenConstants
|
||||||
|
import org.openapitools.codegen.DefaultGenerator
|
||||||
|
import org.openapitools.codegen.config.CodegenConfigurator
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task which generates the desired code.
|
||||||
|
*
|
||||||
|
* Example (CLI):
|
||||||
|
*
|
||||||
|
* ./gradlew -q openApiGenerate
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class GenerateTask : DefaultTask() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The verbosity of generation
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val verbose = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not an input specification should be validated upon generation.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val validateSpec = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the generator which will handle codegen. (see "openApiGenerators" task)
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val generatorName = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The output target directory into which code will be generated.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val outputDir = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Open API 2.0/3.x specification location.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val inputSpec = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template directory holding a custom template.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val templateDir = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds authorization headers when fetching the OpenAPI definitions remotely.
|
||||||
|
* Pass in a URL-encoded string of name:header with a comma separating multiple values
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val auth = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets specified system properties.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val systemProperties = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to json configuration file.
|
||||||
|
* File content should be in a json format { "optionKey":"optionValue", "optionKey1":"optionValue1"...}
|
||||||
|
* Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val configFile = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if the existing files should be overwritten during the generation.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val skipOverwrite = project.objects.property<Boolean?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package for generated api classes
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val apiPackage = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package for generated models
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val modelPackage = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix that will be prepended to all model names. Default is the empty string.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val modelNamePrefix = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suffix that will be appended to all model names. Default is the empty string.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val modelNameSuffix = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets instantiation type mappings.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val instantiationTypes = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets mappings between OpenAPI spec types and generated code types.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val typeMappings = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value.
|
||||||
|
* You can also have multiple occurrences of this option.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val additionalProperties = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val languageSpecificPrimitives = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies mappings between a given class and the import that should be used for that class.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val importMappings = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Root package for generated code.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val invokerPackage = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GroupId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val groupId = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ArtifactId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val id = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Artifact version in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val version = project.objects.property<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference the library template (sub-template) of a generator.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val library = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Git user ID, e.g. openapitools.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val gitUserId = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Git repo ID, e.g. openapi-generator.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val gitRepoId = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release note, default to 'Minor update'.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val releaseNote = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}}/{language}'
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val httpUserAgent = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies how a reserved name should be escaped to.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val reservedWordsMappings = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val ignoreFileOverride = project.objects.property<String?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove prefix of operationId, e.g. config_getId => getId
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val removeOperationIdPrefix = project.objects.property<Boolean?>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines which API-related files should be generated. This allows you to create a subset of generated files (or none at all).
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL api-related files.
|
||||||
|
*
|
||||||
|
* NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results
|
||||||
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val apiFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines which model-related files should be generated. This allows you to create a subset of generated files (or none at all).
|
||||||
|
*
|
||||||
|
* NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results
|
||||||
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val modelFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines which supporting files should be generated. This allows you to create a subset of generated files (or none at all).
|
||||||
|
*
|
||||||
|
* Supporting files are those related to projects/frameworks which may be modified
|
||||||
|
* by consumers.
|
||||||
|
*
|
||||||
|
* NOTE: Configuring any one of [apiFilesConstrainedTo], [modelFilesConstrainedTo], or [supportingFilesConstrainedTo] results
|
||||||
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val supportingFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not model-related _test_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL model-related _test_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val generateModelTests = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not model-related _documentation_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL model-related _documentation_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val generateModelDocumentation = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not api-related _test_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL api-related _test_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val generateApiTests = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether or not api-related _documentation_ files should be generated.
|
||||||
|
*
|
||||||
|
* This option enables/disables generation of ALL api-related _documentation_ files.
|
||||||
|
*
|
||||||
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
|
* refer to it via [ignoreFileOverride].
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val generateApiDocumentation = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A special-case setting which configures some generators with XML support. In some cases,
|
||||||
|
* this forces json OR xml, so the default here is false.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val withXml = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A dynamic map of options specific to a generator.
|
||||||
|
*/
|
||||||
|
@get:Internal
|
||||||
|
val configOptions = project.objects.property<Map<String, String>>()
|
||||||
|
|
||||||
|
private val originalEnvironmentVariables = mutableMapOf<String, String?>()
|
||||||
|
|
||||||
|
private fun <T : Any?> Property<T>.ifNotEmpty(block: Property<T>.(T) -> Unit) {
|
||||||
|
if (isPresent) {
|
||||||
|
val item: T? = get()
|
||||||
|
if (item != null) {
|
||||||
|
when (get()) {
|
||||||
|
is String -> if ((get() as String).isNotEmpty()) {
|
||||||
|
block(get())
|
||||||
|
}
|
||||||
|
is String? -> if (true == (get() as String?)?.isNotEmpty()) {
|
||||||
|
block(get())
|
||||||
|
}
|
||||||
|
else -> block(get())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@TaskAction
|
||||||
|
fun doWork() {
|
||||||
|
val configurator: CodegenConfigurator = if (configFile.isPresent) {
|
||||||
|
CodegenConfigurator.fromFile(configFile.get())
|
||||||
|
} else CodegenConfigurator()
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (systemProperties.isPresent) {
|
||||||
|
systemProperties.get().forEach { (key, value) ->
|
||||||
|
// System.setProperty returns the original value for a key, or null.
|
||||||
|
// Cache the original value or null…we will late put the properties back in their original state.
|
||||||
|
originalEnvironmentVariables[key] = System.setProperty(key, value)
|
||||||
|
configurator.addSystemProperty(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supportingFilesConstrainedTo.isPresent && supportingFilesConstrainedTo.get().isNotEmpty()) {
|
||||||
|
System.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesConstrainedTo.get().joinToString(","))
|
||||||
|
} else {
|
||||||
|
System.clearProperty(CodegenConstants.SUPPORTING_FILES)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelFilesConstrainedTo.isPresent && modelFilesConstrainedTo.get().isNotEmpty()) {
|
||||||
|
System.setProperty(CodegenConstants.MODELS, modelFilesConstrainedTo.get().joinToString(","))
|
||||||
|
} else {
|
||||||
|
System.clearProperty(CodegenConstants.MODELS)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apiFilesConstrainedTo.isPresent && apiFilesConstrainedTo.get().isNotEmpty()) {
|
||||||
|
System.setProperty(CodegenConstants.APIS, apiFilesConstrainedTo.get().joinToString(","))
|
||||||
|
} else {
|
||||||
|
System.clearProperty(CodegenConstants.APIS)
|
||||||
|
}
|
||||||
|
|
||||||
|
System.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.get().toString())
|
||||||
|
System.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.get().toString())
|
||||||
|
System.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.get().toString())
|
||||||
|
System.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString())
|
||||||
|
System.setProperty(CodegenConstants.WITH_XML, withXml.get().toString())
|
||||||
|
|
||||||
|
// now override with any specified parameters
|
||||||
|
verbose.ifNotEmpty { value ->
|
||||||
|
configurator.isVerbose = value
|
||||||
|
}
|
||||||
|
|
||||||
|
validateSpec.ifNotEmpty { value ->
|
||||||
|
configurator.isValidateSpec = value
|
||||||
|
}
|
||||||
|
|
||||||
|
skipOverwrite.ifNotEmpty { value ->
|
||||||
|
configurator.isSkipOverwrite = value ?: false
|
||||||
|
}
|
||||||
|
|
||||||
|
inputSpec.ifNotEmpty { value ->
|
||||||
|
configurator.inputSpec = value
|
||||||
|
}
|
||||||
|
|
||||||
|
generatorName.ifNotEmpty { value ->
|
||||||
|
configurator.generatorName = value
|
||||||
|
}
|
||||||
|
|
||||||
|
outputDir.ifNotEmpty { value ->
|
||||||
|
configurator.outputDir = value
|
||||||
|
}
|
||||||
|
|
||||||
|
auth.ifNotEmpty { value ->
|
||||||
|
configurator.auth = value
|
||||||
|
}
|
||||||
|
|
||||||
|
templateDir.ifNotEmpty { value ->
|
||||||
|
configurator.templateDir = value
|
||||||
|
}
|
||||||
|
|
||||||
|
apiPackage.ifNotEmpty { value ->
|
||||||
|
configurator.apiPackage = value
|
||||||
|
}
|
||||||
|
|
||||||
|
modelPackage.ifNotEmpty { value ->
|
||||||
|
configurator.modelPackage = value
|
||||||
|
}
|
||||||
|
|
||||||
|
modelNamePrefix.ifNotEmpty { value ->
|
||||||
|
configurator.modelNamePrefix = value
|
||||||
|
}
|
||||||
|
|
||||||
|
modelNameSuffix.ifNotEmpty { value ->
|
||||||
|
configurator.modelNameSuffix = value
|
||||||
|
}
|
||||||
|
|
||||||
|
invokerPackage.ifNotEmpty { value ->
|
||||||
|
configurator.invokerPackage = value
|
||||||
|
}
|
||||||
|
|
||||||
|
groupId.ifNotEmpty { value ->
|
||||||
|
configurator.groupId = value
|
||||||
|
}
|
||||||
|
|
||||||
|
id.ifNotEmpty { value ->
|
||||||
|
configurator.artifactId = value
|
||||||
|
}
|
||||||
|
|
||||||
|
version.ifNotEmpty { value ->
|
||||||
|
configurator.artifactVersion = value
|
||||||
|
}
|
||||||
|
|
||||||
|
library.ifNotEmpty { value ->
|
||||||
|
configurator.library = value
|
||||||
|
}
|
||||||
|
|
||||||
|
gitUserId.ifNotEmpty { value ->
|
||||||
|
configurator.gitUserId = value
|
||||||
|
}
|
||||||
|
|
||||||
|
gitRepoId.ifNotEmpty { value ->
|
||||||
|
configurator.gitRepoId = value
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseNote.ifNotEmpty { value ->
|
||||||
|
configurator.releaseNote = value
|
||||||
|
}
|
||||||
|
|
||||||
|
httpUserAgent.ifNotEmpty { value ->
|
||||||
|
configurator.httpUserAgent = value
|
||||||
|
}
|
||||||
|
|
||||||
|
ignoreFileOverride.ifNotEmpty { value ->
|
||||||
|
configurator.ignoreFileOverride = value
|
||||||
|
}
|
||||||
|
|
||||||
|
removeOperationIdPrefix.ifNotEmpty { value ->
|
||||||
|
configurator.removeOperationIdPrefix = value!!
|
||||||
|
}
|
||||||
|
|
||||||
|
if (systemProperties.isPresent) {
|
||||||
|
systemProperties.get().forEach { entry ->
|
||||||
|
configurator.addSystemProperty(entry.key, entry.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instantiationTypes.isPresent) {
|
||||||
|
instantiationTypes.get().forEach { entry ->
|
||||||
|
configurator.addInstantiationType(entry.key, entry.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (importMappings.isPresent) {
|
||||||
|
importMappings.get().forEach { entry ->
|
||||||
|
configurator.addImportMapping(entry.key, entry.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeMappings.isPresent) {
|
||||||
|
typeMappings.get().forEach { entry ->
|
||||||
|
configurator.addTypeMapping(entry.key, entry.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.isPresent) {
|
||||||
|
additionalProperties.get().forEach { entry ->
|
||||||
|
configurator.addAdditionalProperty(entry.key, entry.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (languageSpecificPrimitives.isPresent) {
|
||||||
|
languageSpecificPrimitives.get().forEach {
|
||||||
|
configurator.addLanguageSpecificPrimitive(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reservedWordsMappings.isPresent) {
|
||||||
|
reservedWordsMappings.get().forEach { entry ->
|
||||||
|
configurator.addAdditionalReservedWordMapping(entry.key, entry.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val clientOptInput = configurator.toClientOptInput()
|
||||||
|
val codgenConfig = clientOptInput.config
|
||||||
|
|
||||||
|
if (configOptions.isPresent) {
|
||||||
|
val userSpecifiedConfigOptions = configOptions.get()
|
||||||
|
codgenConfig.cliOptions().forEach {
|
||||||
|
if (userSpecifiedConfigOptions.containsKey(it.opt)) {
|
||||||
|
clientOptInput.config.additionalProperties()[it.opt] = userSpecifiedConfigOptions[it.opt]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
|
||||||
|
out.withStyle(StyledTextOutput.Style.Success)
|
||||||
|
|
||||||
|
DefaultGenerator().opts(clientOptInput).generate()
|
||||||
|
|
||||||
|
out.println("Successfully generated code to ${configurator.outputDir}")
|
||||||
|
} catch (e: RuntimeException) {
|
||||||
|
throw GradleException("Code generation failed.", e)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// Reset all modified system properties back to their original state
|
||||||
|
originalEnvironmentVariables.forEach {
|
||||||
|
when {
|
||||||
|
it.value == null -> System.clearProperty(it.key)
|
||||||
|
else -> System.setProperty(it.key, it.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalEnvironmentVariables.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||||
|
import org.openapitools.codegen.CodegenConfigLoader
|
||||||
|
import org.openapitools.codegen.CodegenType
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task which lists out the generators available in OpenAPI Generator
|
||||||
|
*
|
||||||
|
* Example (CLI):
|
||||||
|
*
|
||||||
|
* ./gradlew -q openApiGenerators
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class GeneratorsTask : DefaultTask() {
|
||||||
|
@Suppress("unused")
|
||||||
|
@TaskAction
|
||||||
|
fun doWork() {
|
||||||
|
val generators = CodegenConfigLoader.getAll()
|
||||||
|
|
||||||
|
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
|
||||||
|
|
||||||
|
StringBuilder().apply {
|
||||||
|
val types = CodegenType.values()
|
||||||
|
|
||||||
|
append("The following generators are available:")
|
||||||
|
|
||||||
|
append(System.lineSeparator())
|
||||||
|
append(System.lineSeparator())
|
||||||
|
|
||||||
|
for (type in types) {
|
||||||
|
append(type.name).append(" generators:")
|
||||||
|
append(System.lineSeparator())
|
||||||
|
|
||||||
|
generators.filter { it.tag == type }
|
||||||
|
.sortedBy { it.name }
|
||||||
|
.forEach({ generator ->
|
||||||
|
append(" - ")
|
||||||
|
append(generator.name)
|
||||||
|
append(System.lineSeparator())
|
||||||
|
})
|
||||||
|
|
||||||
|
append(System.lineSeparator())
|
||||||
|
append(System.lineSeparator())
|
||||||
|
}
|
||||||
|
|
||||||
|
out.withStyle(StyledTextOutput.Style.Success)
|
||||||
|
out.formatln("%s%n", toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin.tasks
|
||||||
|
|
||||||
|
import com.samskivert.mustache.Mustache
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.GradleException
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||||
|
import org.gradle.kotlin.dsl.property
|
||||||
|
import org.openapitools.codegen.CodegenConfig
|
||||||
|
import org.openapitools.codegen.CodegenConstants
|
||||||
|
import org.openapitools.codegen.DefaultGenerator
|
||||||
|
import org.openapitools.codegen.SupportingFile
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task which generates a new generator (meta). Useful for redistributable generator packages.
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class MetaTask : DefaultTask() {
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
val generatorName = project.objects.property<String>()
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
val packageName = project.objects.property<String>()
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
val outputFolder = project.objects.property<String>()
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@TaskAction
|
||||||
|
fun doWork() {
|
||||||
|
|
||||||
|
val packageToPath = packageName.get().replace(".", File.separator)
|
||||||
|
val dir = File(outputFolder.get())
|
||||||
|
val klass = "${generatorName.get().titleCasedTextOnly()}Generator"
|
||||||
|
|
||||||
|
val templateResourceDir = generatorName.get().hyphenatedTextOnly()
|
||||||
|
|
||||||
|
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
|
||||||
|
|
||||||
|
out.withStyle(StyledTextOutput.Style.Info)
|
||||||
|
|
||||||
|
logger.debug("package: {}", packageName.get())
|
||||||
|
logger.debug("dir: {}", dir.absolutePath)
|
||||||
|
logger.debug("generator class: {}", klass)
|
||||||
|
|
||||||
|
val supportingFiles = listOf(
|
||||||
|
SupportingFile("pom.mustache", "", "pom.xml"),
|
||||||
|
SupportingFile("generatorClass.mustache", dir("src", "main", "java", packageToPath), "$klass.java"),
|
||||||
|
SupportingFile("README.mustache", "", "README.md"),
|
||||||
|
SupportingFile("api.template", dir("src", "main", "resources", templateResourceDir), "api.mustache"),
|
||||||
|
SupportingFile("model.template", dir("src", "main", "resources", templateResourceDir), "model.mustache"),
|
||||||
|
SupportingFile("myFile.template", dir("src", "main", "resources", templateResourceDir), "myFile.mustache"),
|
||||||
|
SupportingFile("services.mustache", dir("src", "main", "resources", "META-INF", "services"), CodegenConfig::class.java.canonicalName))
|
||||||
|
|
||||||
|
val currentVersion = CodegenConstants::class.java.`package`.implementationVersion
|
||||||
|
|
||||||
|
val data = mapOf("generatorPackage" to packageToPath,
|
||||||
|
"generatorClass" to klass,
|
||||||
|
"name" to templateResourceDir,
|
||||||
|
"fullyQualifiedGeneratorClass" to "${packageName.get()}.$klass",
|
||||||
|
"openapiGeneratorVersion" to currentVersion)
|
||||||
|
|
||||||
|
val generator = DefaultGenerator()
|
||||||
|
supportingFiles.map {
|
||||||
|
try {
|
||||||
|
val destinationFolder = File(File(dir.absolutePath), it.folder)
|
||||||
|
destinationFolder.mkdirs()
|
||||||
|
val outputFile = File(destinationFolder, it.destinationFilename)
|
||||||
|
|
||||||
|
val template = generator.readTemplate(File("codegen", it.templateFile).path)
|
||||||
|
var formatted = template
|
||||||
|
|
||||||
|
if (it.templateFile.endsWith(".mustache")) {
|
||||||
|
formatted = Mustache.compiler()
|
||||||
|
.withLoader(loader(generator))
|
||||||
|
.defaultValue("")
|
||||||
|
.compile(template).execute(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
outputFile.writeText(formatted, Charset.forName("UTF8"))
|
||||||
|
|
||||||
|
out.formatln("Wrote file to %s", outputFile.absolutePath)
|
||||||
|
|
||||||
|
// TODO: register outputs
|
||||||
|
// return outputFile
|
||||||
|
} catch (e: IOException) {
|
||||||
|
logger.error(e.message)
|
||||||
|
throw GradleException("Can't generate project", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.withStyle(StyledTextOutput.Style.Success)
|
||||||
|
out.formatln("Created generator %s", klass)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loader(generator: DefaultGenerator): Mustache.TemplateLoader {
|
||||||
|
return Mustache.TemplateLoader { name ->
|
||||||
|
generator.getTemplateReader("codegen${File.separator}$name.mustache")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.titleCasedTextOnly(): String =
|
||||||
|
this.split(Regex("[^a-zA-Z0-9]")).joinToString(separator = "", transform = String::capitalize)
|
||||||
|
|
||||||
|
private fun String.hyphenatedTextOnly(): String =
|
||||||
|
this.split(Regex("[^a-zA-Z0-9]")).joinToString(separator = "-", transform = String::toLowerCase)
|
||||||
|
|
||||||
|
private fun dir(vararg parts: String): String =
|
||||||
|
parts.joinToString(separator = File.separator)
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.generator.gradle.plugin.tasks
|
||||||
|
|
||||||
|
import io.swagger.parser.OpenAPIParser
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.GradleException
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.api.tasks.options.Option
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
|
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||||
|
import org.gradle.kotlin.dsl.property
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generator which validates an Open API spec. This task outputs a list of validation issues and errors.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* cli:
|
||||||
|
*
|
||||||
|
* ./gradlew openApiValidate --input=/path/to/file
|
||||||
|
*
|
||||||
|
* build.gradle:
|
||||||
|
*
|
||||||
|
* openApiMeta {
|
||||||
|
* inputSpec = "path/to/spec.yaml"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @author Jim Schubert
|
||||||
|
*/
|
||||||
|
open class ValidateTask : DefaultTask() {
|
||||||
|
@get:Internal
|
||||||
|
var inputSpec = project.objects.property<String>()
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@get:Internal
|
||||||
|
@set:Option(option = "input", description = "The input specification.")
|
||||||
|
var input: String? = null
|
||||||
|
set(value) {
|
||||||
|
inputSpec.set(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@TaskAction
|
||||||
|
fun doWork() {
|
||||||
|
val spec = inputSpec.get()
|
||||||
|
logger.quiet("Validating spec $spec")
|
||||||
|
val result = OpenAPIParser().readLocation(spec, null, null)
|
||||||
|
val messages = result.messages.toSet()
|
||||||
|
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
|
||||||
|
|
||||||
|
if (messages.isNotEmpty()) {
|
||||||
|
|
||||||
|
out.withStyle(StyledTextOutput.Style.Error)
|
||||||
|
out.println("\nSpec is invalid.\nIssues:\n")
|
||||||
|
|
||||||
|
messages.forEach {
|
||||||
|
out.withStyle(StyledTextOutput.Style.Error)
|
||||||
|
out.println("\t$it\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
throw GradleException("Validation failed.")
|
||||||
|
} else {
|
||||||
|
out.withStyle(StyledTextOutput.Style.Success)
|
||||||
|
out.println("Spec is valid.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package org.openapitools.generator.gradle.plugin
|
||||||
|
|
||||||
|
import org.gradle.testkit.runner.GradleRunner
|
||||||
|
import org.gradle.testkit.runner.TaskOutcome
|
||||||
|
import org.testng.annotations.Test
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class GenerateTaskDslTest : TestBase() {
|
||||||
|
override var temp: File = createTempDir(javaClass.simpleName)
|
||||||
|
|
||||||
|
private val defaultBuildGradle = """
|
||||||
|
plugins {
|
||||||
|
id 'org.openapi.generator'
|
||||||
|
}
|
||||||
|
openApiGenerate {
|
||||||
|
generatorName = "kotlin"
|
||||||
|
inputSpec = file("spec.yaml").absolutePath
|
||||||
|
outputDir = file("build/kotlin").absolutePath
|
||||||
|
apiPackage = "org.openapitools.example.api"
|
||||||
|
invokerPackage = "org.openapitools.example.invoker"
|
||||||
|
modelPackage = "org.openapitools.example.model"
|
||||||
|
configOptions = [
|
||||||
|
dateLibrary: "java8"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiGenerate should create an expected file structure from DSL config`() {
|
||||||
|
// Arrange
|
||||||
|
val projectFiles = mapOf(
|
||||||
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
||||||
|
)
|
||||||
|
withProject(defaultBuildGradle, projectFiles)
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiGenerate")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(result.output.contains("Successfully generated code to"), "User friendly generate notice is missing.")
|
||||||
|
|
||||||
|
listOf(
|
||||||
|
"build/kotlin/.openapi-generator-ignore",
|
||||||
|
"build/kotlin/docs/PetsApi.md",
|
||||||
|
"build/kotlin/docs/Pets.md",
|
||||||
|
"build/kotlin/docs/Error.md",
|
||||||
|
"build/kotlin/docs/Pet.md",
|
||||||
|
"build/kotlin/README.md",
|
||||||
|
"build/kotlin/build.gradle",
|
||||||
|
"build/kotlin/.openapi-generator/VERSION",
|
||||||
|
"build/kotlin/settings.gradle",
|
||||||
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Pets.kt",
|
||||||
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Pet.kt",
|
||||||
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Error.kt",
|
||||||
|
"build/kotlin/src/main/kotlin/org/openapitools/example/api/PetsApi.kt",
|
||||||
|
"build/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt"
|
||||||
|
).map {
|
||||||
|
val f = File(temp, it)
|
||||||
|
assertTrue(f.exists() && f.isFile, "An expected file was not generated when invoking the generation.")
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,
|
||||||
|
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package org.openapitools.generator.gradle.plugin
|
||||||
|
|
||||||
|
import org.gradle.testkit.runner.GradleRunner
|
||||||
|
import org.gradle.testkit.runner.TaskOutcome
|
||||||
|
import org.testng.annotations.Test
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class GeneratorsTaskDslTest : TestBase() {
|
||||||
|
override var temp: File = createTempDir(javaClass.simpleName)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiGenerators should list generators available to the user`() {
|
||||||
|
// Arrange
|
||||||
|
withProject("""
|
||||||
|
| plugins {
|
||||||
|
| id 'org.openapi.generator'
|
||||||
|
| }
|
||||||
|
""".trimMargin())
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiGenerators")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(result.output.contains("The following generators are available:"), "User friendly generator notice is missing.")
|
||||||
|
assertTrue(result.output.contains("CLIENT generators:"), "Expected client generator header is missing.")
|
||||||
|
assertTrue(result.output.contains("android"), "Spot-checking listed client generators is missing a client generator.")
|
||||||
|
assertTrue(result.output.contains("SERVER generators:"), "Expected server generator header is missing.")
|
||||||
|
assertTrue(result.output.contains("kotlin-server"), "Spot-checking listed server generators is missing a server generator.")
|
||||||
|
assertEquals(TaskOutcome.SUCCESS, result.task(":openApiGenerators")?.outcome,
|
||||||
|
"Expected a successful run, but found ${result.task(":openApiGenerators")?.outcome}")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package org.openapitools.generator.gradle.plugin
|
||||||
|
|
||||||
|
import org.gradle.testkit.runner.GradleRunner
|
||||||
|
import org.gradle.testkit.runner.TaskOutcome
|
||||||
|
import org.testng.annotations.Test
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class MetaTaskDslTest : TestBase() {
|
||||||
|
override var temp: File = createTempDir(javaClass.simpleName)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiMeta should generate desired project contents`() {
|
||||||
|
// Arrange
|
||||||
|
val buildDirReplacement = "\$buildDir/meta"
|
||||||
|
withProject("""
|
||||||
|
| plugins {
|
||||||
|
| id 'org.openapi.generator'
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| openApiMeta {
|
||||||
|
| generatorName = "Sample"
|
||||||
|
| packageName = "org.openapitools.example"
|
||||||
|
| outputFolder = "$buildDirReplacement".toString()
|
||||||
|
| }
|
||||||
|
""".trimMargin())
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiMeta")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(result.output.contains("Wrote file to"), "User friendly write notice is missing.")
|
||||||
|
|
||||||
|
// To avoid any OS-specific output causing issues with our stdout comparisons, only compare on expected filenames.
|
||||||
|
listOf(
|
||||||
|
"SampleGenerator.java",
|
||||||
|
"README.md",
|
||||||
|
"api.mustache",
|
||||||
|
"model.mustache",
|
||||||
|
"myFile.mustache",
|
||||||
|
"org.openapitools.codegen.CodegenConfig",
|
||||||
|
"pom.xml"
|
||||||
|
).map {
|
||||||
|
assertTrue(result.output.contains(it), "Expected $it to be listed in gradle stdout.")
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
TaskOutcome.SUCCESS,
|
||||||
|
result.task(":openApiMeta")?.outcome,
|
||||||
|
"Expected a successful run, but found ${result.task(":openApiMeta")?.outcome}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
34
modules/openapi-generator-gradle-plugin/bin/test/TestBase.kt
Normal file
34
modules/openapi-generator-gradle-plugin/bin/test/TestBase.kt
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package org.openapitools.generator.gradle.plugin
|
||||||
|
|
||||||
|
import org.testng.annotations.AfterMethod
|
||||||
|
import org.testng.annotations.BeforeMethod
|
||||||
|
import java.io.File
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
abstract class TestBase {
|
||||||
|
protected open lateinit var temp: File
|
||||||
|
|
||||||
|
@BeforeMethod
|
||||||
|
protected fun before() {
|
||||||
|
temp = createTempDir(javaClass.simpleName)
|
||||||
|
temp.deleteOnExit()
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterMethod
|
||||||
|
protected fun after(){
|
||||||
|
temp.deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun withProject(
|
||||||
|
buildContents: String,
|
||||||
|
projectFiles: Map<String, InputStream> = mapOf()
|
||||||
|
) {
|
||||||
|
val buildFile = File(temp,"build.gradle")
|
||||||
|
buildFile.writeText(buildContents)
|
||||||
|
|
||||||
|
projectFiles.forEach { entry ->
|
||||||
|
val target = File(temp, entry.key)
|
||||||
|
entry.value.copyTo(target.outputStream())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package org.openapitools.generator.gradle.plugin
|
||||||
|
|
||||||
|
import org.gradle.testkit.runner.GradleRunner
|
||||||
|
import org.gradle.testkit.runner.TaskOutcome.FAILED
|
||||||
|
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
|
||||||
|
import org.testng.annotations.Test
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class ValidateTaskDslTest : TestBase() {
|
||||||
|
override var temp: File = createTempDir(javaClass.simpleName)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiValidate should fail on non-file spec`() {
|
||||||
|
// Arrange
|
||||||
|
withProject("""
|
||||||
|
| plugins {
|
||||||
|
| id 'org.openapi.generator'
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| openApiValidate {
|
||||||
|
| inputSpec = "some_location"
|
||||||
|
| }
|
||||||
|
""".trimMargin())
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiValidate")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.buildAndFail()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(result.output.contains("unable to read location `some_location`"), "Unexpected/no message presented to the user for a spec pointing to an invalid URI.")
|
||||||
|
assertEquals(FAILED, result.task(":openApiValidate")?.outcome,
|
||||||
|
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiValidate should succeed on valid spec`() {
|
||||||
|
// Arrange
|
||||||
|
val projectFiles = mapOf(
|
||||||
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
||||||
|
)
|
||||||
|
|
||||||
|
withProject("""
|
||||||
|
| plugins {
|
||||||
|
| id 'org.openapi.generator'
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| openApiValidate {
|
||||||
|
| inputSpec = file("spec.yaml").absolutePath
|
||||||
|
| }
|
||||||
|
""".trimMargin(), projectFiles)
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiValidate")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(result.output.contains("Spec is valid."), "Unexpected/no message presented to the user for a valid spec.")
|
||||||
|
assertEquals(SUCCESS, result.task(":openApiValidate")?.outcome,
|
||||||
|
"Expected a successful run, but found ${result.task(":openApiValidate")?.outcome}")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiValidate should fail on invalid spec`() {
|
||||||
|
// Arrange
|
||||||
|
val projectFiles = mapOf(
|
||||||
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
|
||||||
|
)
|
||||||
|
withProject("""
|
||||||
|
| plugins {
|
||||||
|
| id 'org.openapi.generator'
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| openApiValidate {
|
||||||
|
| inputSpec = file('spec.yaml').absolutePath
|
||||||
|
| }
|
||||||
|
""".trimMargin(), projectFiles)
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiValidate")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.buildAndFail()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(result.output.contains("Spec is invalid."), "Unexpected/no message presented to the user for an invalid spec.")
|
||||||
|
assertEquals(FAILED, result.task(":openApiValidate")?.outcome,
|
||||||
|
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
openapi: "3.0.0"
|
||||||
|
servers:
|
||||||
|
- url: http://petstore.swagger.io/v1
|
||||||
|
paths:
|
||||||
|
/pets:
|
||||||
|
get:
|
||||||
|
summary: List all pets
|
||||||
|
operationId: listPets
|
||||||
|
tags:
|
||||||
|
- pets
|
||||||
|
parameters:
|
||||||
|
- name: limit
|
||||||
|
in: query
|
||||||
|
description: How many items to return at one time (max 100)
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: A paged array of pets
|
||||||
|
headers:
|
||||||
|
x-next:
|
||||||
|
description: A link to the next page of responses
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pets"
|
||||||
|
default:
|
||||||
|
description: unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
post:
|
||||||
|
summary: Create a pet
|
||||||
|
tags:
|
||||||
|
- pets
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
description: Null response
|
||||||
|
default:
|
||||||
|
description: unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
/pets/{petId}:
|
||||||
|
get:
|
||||||
|
summary: Info for a specific pet
|
||||||
|
operationId: showPetById
|
||||||
|
tags:
|
||||||
|
- pets
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The id of the pet to retrieve
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Expected response to a valid request
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pets"
|
||||||
|
default:
|
||||||
|
description: unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Pet:
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
tag:
|
||||||
|
type: string
|
||||||
|
Pets:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
Error:
|
||||||
|
required:
|
||||||
|
- code
|
||||||
|
- message
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
message:
|
||||||
|
type: string
|
@ -0,0 +1,109 @@
|
|||||||
|
openapi: "3.0.0"
|
||||||
|
info:
|
||||||
|
version: 1.0.0
|
||||||
|
title: Swagger Petstore
|
||||||
|
license:
|
||||||
|
name: MIT
|
||||||
|
servers:
|
||||||
|
- url: http://petstore.swagger.io/v1
|
||||||
|
paths:
|
||||||
|
/pets:
|
||||||
|
get:
|
||||||
|
summary: List all pets
|
||||||
|
operationId: listPets
|
||||||
|
tags:
|
||||||
|
- pets
|
||||||
|
parameters:
|
||||||
|
- name: limit
|
||||||
|
in: query
|
||||||
|
description: How many items to return at one time (max 100)
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: A paged array of pets
|
||||||
|
headers:
|
||||||
|
x-next:
|
||||||
|
description: A link to the next page of responses
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pets"
|
||||||
|
default:
|
||||||
|
description: unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
post:
|
||||||
|
summary: Create a pet
|
||||||
|
operationId: createPets
|
||||||
|
tags:
|
||||||
|
- pets
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
description: Null response
|
||||||
|
default:
|
||||||
|
description: unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
/pets/{petId}:
|
||||||
|
get:
|
||||||
|
summary: Info for a specific pet
|
||||||
|
operationId: showPetById
|
||||||
|
tags:
|
||||||
|
- pets
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The id of the pet to retrieve
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Expected response to a valid request
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pets"
|
||||||
|
default:
|
||||||
|
description: unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Pet:
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
tag:
|
||||||
|
type: string
|
||||||
|
Pets:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
Error:
|
||||||
|
required:
|
||||||
|
- code
|
||||||
|
- message
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
message:
|
||||||
|
type: string
|
@ -22,12 +22,17 @@ import io.swagger.v3.oas.models.media.Schema;
|
|||||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||||
import org.openapitools.codegen.CliOption;
|
import org.openapitools.codegen.CliOption;
|
||||||
import org.openapitools.codegen.CodegenModel;
|
import org.openapitools.codegen.CodegenModel;
|
||||||
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
import org.openapitools.codegen.SupportingFile;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
|
import org.openapitools.codegen.CodegenConstants.MODEL_PROPERTY_NAMING_TYPE;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen {
|
public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||||
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
|
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
|
||||||
@ -52,6 +57,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
outputFolder = "generated-code/typescript-fetch";
|
outputFolder = "generated-code/typescript-fetch";
|
||||||
embeddedTemplateDir = templateDir = "typescript-fetch";
|
embeddedTemplateDir = templateDir = "typescript-fetch";
|
||||||
|
|
||||||
|
this.apiPackage = "apis";
|
||||||
|
this.apiTemplateFiles.put("apis.mustache", ".ts");
|
||||||
|
this.modelPackage = "models";
|
||||||
|
this.modelTemplateFiles.put("models.mustache", ".ts");
|
||||||
|
this.addExtraReservedWords();
|
||||||
|
|
||||||
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
|
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
|
||||||
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"));
|
||||||
@ -96,13 +107,13 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
additionalProperties.put("isOriginalModelPropertyNaming", getModelPropertyNaming().equals("original"));
|
||||||
|
additionalProperties.put("modelPropertyNaming", getModelPropertyNaming());
|
||||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts"));
|
supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts"));
|
||||||
supportingFiles.add(new SupportingFile("api.mustache", "", "api.ts"));
|
supportingFiles.add(new SupportingFile("runtime.mustache", "", "runtime.ts"));
|
||||||
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts"));
|
supportingFiles.add(new SupportingFile("apis.index.mustache", apiPackage().replace('.', File.separatorChar), "index.ts"));
|
||||||
supportingFiles.add(new SupportingFile("custom.d.mustache", "", "custom.d.ts"));
|
supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||||
addNpmPackageGeneration();
|
addNpmPackageGeneration();
|
||||||
}
|
}
|
||||||
@ -118,9 +129,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
inner = ModelUtils.getAdditionalProperties(p);
|
inner = ModelUtils.getAdditionalProperties(p);
|
||||||
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
||||||
} else if (ModelUtils.isFileSchema(p)) {
|
} else if (ModelUtils.isFileSchema(p)) {
|
||||||
return "any";
|
return "Blob";
|
||||||
} else if (ModelUtils.isBinarySchema(p)) {
|
} else if (ModelUtils.isBinarySchema(p)) {
|
||||||
return "any";
|
return "Blob";
|
||||||
} else {
|
} else {
|
||||||
return super.getTypeDeclaration(p);
|
return super.getTypeDeclaration(p);
|
||||||
}
|
}
|
||||||
@ -132,6 +143,20 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
addImport(codegenModel, codegenModel.additionalPropertiesType);
|
addImport(codegenModel, codegenModel.additionalPropertiesType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||||
|
Map<String, Object> result = super.postProcessAllModels(objs);
|
||||||
|
for (Map.Entry<String, Object> entry : result.entrySet()) {
|
||||||
|
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
||||||
|
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||||
|
for (Map<String, Object> model : models) {
|
||||||
|
CodegenModel codegenModel = (CodegenModel) model.get("model");
|
||||||
|
model.put("hasImports", codegenModel.imports.size() > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
@ -153,7 +178,48 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
//Files for building our lib
|
//Files for building our lib
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||||
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
|
||||||
|
this.addOperationModelImportInfomation(operations);
|
||||||
|
return operations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addOperationModelImportInfomation(Map<String, Object> operations) {
|
||||||
|
// This method will add extra infomation to the operations.imports array.
|
||||||
|
// The api template uses this infomation to import all the required
|
||||||
|
// models for a given operation.
|
||||||
|
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||||
|
for (Map<String, Object> im : imports) {
|
||||||
|
im.put("className", im.get("import").toString().replace("models.", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addExtraReservedWords() {
|
||||||
|
this.reservedWords.add("BASE_PATH");
|
||||||
|
this.reservedWords.add("BaseAPI");
|
||||||
|
this.reservedWords.add("RequiredError");
|
||||||
|
this.reservedWords.add("COLLECTION_FORMATS");
|
||||||
|
this.reservedWords.add("FetchAPI");
|
||||||
|
this.reservedWords.add("ConfigurationParameters");
|
||||||
|
this.reservedWords.add("Configuration");
|
||||||
|
this.reservedWords.add("HTTPMethod");
|
||||||
|
this.reservedWords.add("HTTPHeaders");
|
||||||
|
this.reservedWords.add("HTTPQuery");
|
||||||
|
this.reservedWords.add("HTTPBody");
|
||||||
|
this.reservedWords.add("ModelPropertyNaming");
|
||||||
|
this.reservedWords.add("FetchParams");
|
||||||
|
this.reservedWords.add("RequestOpts");
|
||||||
|
this.reservedWords.add("exists");
|
||||||
|
this.reservedWords.add("RequestContext");
|
||||||
|
this.reservedWords.add("ResponseContext");
|
||||||
|
this.reservedWords.add("Middleware");
|
||||||
|
this.reservedWords.add("ApiResponse");
|
||||||
|
this.reservedWords.add("ResponseTransformer");
|
||||||
|
this.reservedWords.add("JSONApiResponse");
|
||||||
|
this.reservedWords.add("VoidApiResponse");
|
||||||
|
this.reservedWords.add("BlobApiResponse");
|
||||||
|
this.reservedWords.add("TextApiResponse");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,368 +0,0 @@
|
|||||||
/// <reference path="./custom.d.ts" />
|
|
||||||
// tslint:disable
|
|
||||||
{{>licenseInfo}}
|
|
||||||
|
|
||||||
import * as url from "url";
|
|
||||||
import * as portableFetch from "portable-fetch";
|
|
||||||
import { Configuration } from "./configuration";
|
|
||||||
|
|
||||||
const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
*/
|
|
||||||
export const COLLECTION_FORMATS = {
|
|
||||||
csv: ",",
|
|
||||||
ssv: " ",
|
|
||||||
tsv: "\t",
|
|
||||||
pipes: "|",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface FetchAPI
|
|
||||||
*/
|
|
||||||
export interface FetchAPI {
|
|
||||||
(url: string, init?: any): Promise<Response>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface FetchArgs
|
|
||||||
*/
|
|
||||||
export interface FetchArgs {
|
|
||||||
url: string;
|
|
||||||
options: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @class BaseAPI
|
|
||||||
*/
|
|
||||||
export class BaseAPI {
|
|
||||||
protected configuration: Configuration | undefined;
|
|
||||||
|
|
||||||
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) {
|
|
||||||
if (configuration) {
|
|
||||||
this.configuration = configuration;
|
|
||||||
this.basePath = configuration.basePath || this.basePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @class RequiredError
|
|
||||||
* @extends {Error}
|
|
||||||
*/
|
|
||||||
export class RequiredError extends Error {
|
|
||||||
name: "RequiredError" = "RequiredError";
|
|
||||||
constructor(public field: string, msg?: string) {
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#models}}
|
|
||||||
{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}}
|
|
||||||
{{/models}}
|
|
||||||
{{#apiInfo}}{{#apis}}{{#operations}}
|
|
||||||
/**
|
|
||||||
* {{classname}} - fetch parameter creator{{#description}}
|
|
||||||
* {{&description}}{{/description}}
|
|
||||||
* @export
|
|
||||||
*/
|
|
||||||
export const {{classname}}FetchParamCreator = function (configuration?: Configuration) {
|
|
||||||
return {
|
|
||||||
{{#operation}}
|
|
||||||
/**
|
|
||||||
* {{¬es}}
|
|
||||||
{{#summary}}
|
|
||||||
* @summary {{&summary}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#allParams}}
|
|
||||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
|
||||||
{{/allParams}}
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: any = {}): FetchArgs {
|
|
||||||
{{#allParams}}
|
|
||||||
{{#required}}
|
|
||||||
// verify required parameter '{{paramName}}' is not null or undefined
|
|
||||||
if ({{paramName}} === null || {{paramName}} === undefined) {
|
|
||||||
throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
{{/allParams}}
|
|
||||||
const localVarPath = `{{{path}}}`{{#pathParams}}
|
|
||||||
.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}};
|
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
|
||||||
let baseOptions;
|
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: '{{httpMethod}}' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
|
||||||
const localVarQueryParameter = {} as any;
|
|
||||||
{{#hasFormParams}}
|
|
||||||
const localVarFormParams = new url.URLSearchParams();
|
|
||||||
{{/hasFormParams}}
|
|
||||||
|
|
||||||
{{#authMethods}}
|
|
||||||
// authentication {{name}} required
|
|
||||||
{{#isApiKey}}
|
|
||||||
{{#isKeyInHeader}}
|
|
||||||
if (configuration && configuration.apiKey) {
|
|
||||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
||||||
? configuration.apiKey("{{keyParamName}}")
|
|
||||||
: configuration.apiKey;
|
|
||||||
localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
|
||||||
}
|
|
||||||
{{/isKeyInHeader}}
|
|
||||||
{{#isKeyInQuery}}
|
|
||||||
if (configuration && configuration.apiKey) {
|
|
||||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
||||||
? configuration.apiKey("{{keyParamName}}")
|
|
||||||
: configuration.apiKey;
|
|
||||||
localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
|
||||||
}
|
|
||||||
{{/isKeyInQuery}}
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isBasic}}
|
|
||||||
// http basic authentication required
|
|
||||||
if (configuration && (configuration.username || configuration.password)) {
|
|
||||||
localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password);
|
|
||||||
}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
// oauth required
|
|
||||||
if (configuration && configuration.accessToken) {
|
|
||||||
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
||||||
? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
|
|
||||||
: configuration.accessToken;
|
|
||||||
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
||||||
}
|
|
||||||
{{/isOAuth}}
|
|
||||||
|
|
||||||
{{/authMethods}}
|
|
||||||
{{#queryParams}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
if ({{paramName}}) {
|
|
||||||
{{#isCollectionFormatMulti}}
|
|
||||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
|
||||||
{{/isCollectionFormatMulti}}
|
|
||||||
{{^isCollectionFormatMulti}}
|
|
||||||
localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
|
|
||||||
{{/isCollectionFormatMulti}}
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
if ({{paramName}} !== undefined) {
|
|
||||||
{{#isDateTime}}
|
|
||||||
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString();
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{^isDateTime}}
|
|
||||||
{{#isDate}}
|
|
||||||
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString();
|
|
||||||
{{/isDate}}
|
|
||||||
{{^isDate}}
|
|
||||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
|
||||||
{{/isDate}}
|
|
||||||
{{/isDateTime}}
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
|
|
||||||
{{/queryParams}}
|
|
||||||
{{#headerParams}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
if ({{paramName}}) {
|
|
||||||
localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
if ({{paramName}} !== undefined && {{paramName}} !== null) {
|
|
||||||
localVarHeaderParameter['{{baseName}}'] = String({{paramName}});
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
|
|
||||||
{{/headerParams}}
|
|
||||||
{{#formParams}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
if ({{paramName}}) {
|
|
||||||
{{#isCollectionFormatMulti}}
|
|
||||||
{{paramName}}.forEach((element) => {
|
|
||||||
localVarFormParams.append('{{baseName}}', element as any);
|
|
||||||
})
|
|
||||||
{{/isCollectionFormatMulti}}
|
|
||||||
{{^isCollectionFormatMulti}}
|
|
||||||
localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
|
|
||||||
{{/isCollectionFormatMulti}}
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
if ({{paramName}} !== undefined) {
|
|
||||||
localVarFormParams.set('{{baseName}}', {{paramName}} as any);
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
|
|
||||||
{{/formParams}}
|
|
||||||
{{#hasFormParams}}
|
|
||||||
localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
||||||
|
|
||||||
{{/hasFormParams}}
|
|
||||||
{{#bodyParam}}
|
|
||||||
{{^consumes}}
|
|
||||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
||||||
{{/consumes}}
|
|
||||||
{{#consumes.0}}
|
|
||||||
localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}';
|
|
||||||
{{/consumes.0}}
|
|
||||||
|
|
||||||
{{/bodyParam}}
|
|
||||||
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
|
|
||||||
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
|
||||||
delete localVarUrlObj.search;
|
|
||||||
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
|
|
||||||
{{#hasFormParams}}
|
|
||||||
localVarRequestOptions.body = localVarFormParams.toString();
|
|
||||||
{{/hasFormParams}}
|
|
||||||
{{#bodyParam}}
|
|
||||||
const needsSerialization = (<any>"{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
|
||||||
localVarRequestOptions.body = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || "");
|
|
||||||
{{/bodyParam}}
|
|
||||||
|
|
||||||
return {
|
|
||||||
url: url.format(localVarUrlObj),
|
|
||||||
options: localVarRequestOptions,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {{classname}} - functional programming interface{{#description}}
|
|
||||||
* {{{description}}}{{/description}}
|
|
||||||
* @export
|
|
||||||
*/
|
|
||||||
export const {{classname}}Fp = function(configuration?: Configuration) {
|
|
||||||
return {
|
|
||||||
{{#operation}}
|
|
||||||
/**
|
|
||||||
* {{¬es}}
|
|
||||||
{{#summary}}
|
|
||||||
* @summary {{&summary}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#allParams}}
|
|
||||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
|
||||||
{{/allParams}}
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
|
|
||||||
const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
|
|
||||||
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
|
|
||||||
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
||||||
if (response.status >= 200 && response.status < 300) {
|
|
||||||
return response{{#returnType}}.json(){{/returnType}};
|
|
||||||
} else {
|
|
||||||
throw response;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
},
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {{classname}} - factory interface{{#description}}
|
|
||||||
* {{&description}}{{/description}}
|
|
||||||
* @export
|
|
||||||
*/
|
|
||||||
export const {{classname}}Factory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) {
|
|
||||||
return {
|
|
||||||
{{#operation}}
|
|
||||||
/**
|
|
||||||
* {{¬es}}
|
|
||||||
{{#summary}}
|
|
||||||
* @summary {{&summary}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#allParams}}
|
|
||||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
|
||||||
{{/allParams}}
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) {
|
|
||||||
return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(fetch, basePath);
|
|
||||||
},
|
|
||||||
{{/operation}}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
{{#withInterfaces}}
|
|
||||||
/**
|
|
||||||
* {{classname}} - interface{{#description}}
|
|
||||||
* {{&description}}{{/description}}
|
|
||||||
* @export
|
|
||||||
* @interface {{classname}}
|
|
||||||
*/
|
|
||||||
export interface {{classname}}Interface {
|
|
||||||
{{#operation}}
|
|
||||||
/**
|
|
||||||
* {{¬es}}
|
|
||||||
{{#summary}}
|
|
||||||
* @summary {{&summary}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#allParams}}
|
|
||||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
|
||||||
{{/allParams}}
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
* @memberof {{classname}}Interface
|
|
||||||
*/
|
|
||||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}>;
|
|
||||||
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/withInterfaces}}
|
|
||||||
/**
|
|
||||||
* {{classname}} - object-oriented interface{{#description}}
|
|
||||||
* {{{description}}}{{/description}}
|
|
||||||
* @export
|
|
||||||
* @class {{classname}}
|
|
||||||
* @extends {BaseAPI}
|
|
||||||
*/
|
|
||||||
{{#withInterfaces}}
|
|
||||||
export class {{classname}} extends BaseAPI implements {{classname}}Interface {
|
|
||||||
{{/withInterfaces}}
|
|
||||||
{{^withInterfaces}}
|
|
||||||
export class {{classname}} extends BaseAPI {
|
|
||||||
{{/withInterfaces}}
|
|
||||||
{{#operation}}
|
|
||||||
/**
|
|
||||||
* {{¬es}}
|
|
||||||
{{#summary}}
|
|
||||||
* @summary {{&summary}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#allParams}}
|
|
||||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
|
||||||
{{/allParams}}
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
* @memberof {{classname}}
|
|
||||||
*/
|
|
||||||
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) {
|
|
||||||
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(this.fetch, this.basePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
{{/operations}}{{/apis}}{{/apiInfo}}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
{{#apiInfo}}
|
||||||
|
{{#apis}}
|
||||||
|
{{#operations}}
|
||||||
|
export * from './{{ classFilename }}';
|
||||||
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
{{/apiInfo}}
|
@ -0,0 +1,245 @@
|
|||||||
|
// tslint:disable
|
||||||
|
{{>licenseInfo}}
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
{{#imports.0}}
|
||||||
|
import {
|
||||||
|
{{#imports}}
|
||||||
|
{{className}},
|
||||||
|
{{className}}FromJSON,
|
||||||
|
{{className}}ToJSON,
|
||||||
|
{{/imports}}
|
||||||
|
} from '../models';
|
||||||
|
{{/imports.0}}
|
||||||
|
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
{{#allParams.0}}
|
||||||
|
export interface {{operationIdCamelCase}}Request {
|
||||||
|
{{#allParams}}
|
||||||
|
{{paramName}}{{^required}}?{{/required}}: {{{dataType}}};
|
||||||
|
{{/allParams}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/allParams.0}}
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
{{#operations}}
|
||||||
|
/**
|
||||||
|
* {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}}
|
||||||
|
*/
|
||||||
|
export class {{classname}} extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
{{#operation}}
|
||||||
|
/**
|
||||||
|
{{#notes}}
|
||||||
|
* {{¬es}}
|
||||||
|
{{/notes}}
|
||||||
|
{{#summary}}
|
||||||
|
* {{&summary}}
|
||||||
|
{{/summary}}
|
||||||
|
*/
|
||||||
|
async {{nickname}}Raw({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise<runtime.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}>> {
|
||||||
|
{{#allParams}}
|
||||||
|
{{#required}}
|
||||||
|
if (requestParameters.{{paramName}} === null || requestParameters.{{paramName}} === undefined) {
|
||||||
|
throw new runtime.RequiredError('{{paramName}}','Required parameter requestParameters.{{paramName}} was null or undefined when calling {{nickname}}.');
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/required}}
|
||||||
|
{{/allParams}}
|
||||||
|
{{#hasQueryParams}}
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
{{/hasQueryParams}}
|
||||||
|
{{#queryParams}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
if (requestParameters.{{paramName}}) {
|
||||||
|
{{#isCollectionFormatMulti}}
|
||||||
|
queryParameters['{{baseName}}'] = requestParameters.{{paramName}};
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
|
{{^isCollectionFormatMulti}}
|
||||||
|
queryParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]);
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{^isListContainer}}
|
||||||
|
if (requestParameters.{{paramName}} !== undefined) {
|
||||||
|
{{#isDateTime}}
|
||||||
|
queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString();
|
||||||
|
{{/isDateTime}}
|
||||||
|
{{^isDateTime}}
|
||||||
|
{{#isDate}}
|
||||||
|
queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString();
|
||||||
|
{{/isDate}}
|
||||||
|
{{^isDate}}
|
||||||
|
queryParameters['{{baseName}}'] = requestParameters.{{paramName}};
|
||||||
|
{{/isDate}}
|
||||||
|
{{/isDateTime}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{/queryParams}}
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
{{#bodyParam}}
|
||||||
|
{{^consumes}}
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
{{/consumes}}
|
||||||
|
{{#consumes.0}}
|
||||||
|
headerParameters['Content-Type'] = '{{{mediaType}}}';
|
||||||
|
|
||||||
|
{{/consumes.0}}
|
||||||
|
{{/bodyParam}}
|
||||||
|
{{#headerParams}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
if (requestParameters.{{paramName}}) {
|
||||||
|
headerParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]));
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{^isListContainer}}
|
||||||
|
if (requestParameters.{{paramName}} !== undefined && requestParameters.{{paramName}} !== null) {
|
||||||
|
headerParameters['{{baseName}}'] = String(requestParameters.{{paramName}});
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{/headerParams}}
|
||||||
|
{{#authMethods}}
|
||||||
|
{{#isBasic}}
|
||||||
|
if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
|
||||||
|
headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isBasic}}
|
||||||
|
{{#isApiKey}}
|
||||||
|
{{#isKeyInHeader}}
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
headerParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isKeyInHeader}}
|
||||||
|
{{#isKeyInQuery}}
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
queryParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isKeyInQuery}}
|
||||||
|
{{/isApiKey}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
{{#hasFormParams}}
|
||||||
|
const formData = new FormData();
|
||||||
|
{{/hasFormParams}}
|
||||||
|
{{#formParams}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
if (requestParameters.{{paramName}}) {
|
||||||
|
{{#isCollectionFormatMulti}}
|
||||||
|
requestParameters.{{paramName}}.forEach((element) => {
|
||||||
|
formData.append('{{baseName}}', element as any);
|
||||||
|
})
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
|
{{^isCollectionFormatMulti}}
|
||||||
|
formData.append('{{baseName}}', requestParameters.{{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
|
||||||
|
{{/isCollectionFormatMulti}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{^isListContainer}}
|
||||||
|
if (requestParameters.{{paramName}} !== undefined) {
|
||||||
|
formData.append('{{baseName}}', requestParameters.{{paramName}} as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{/formParams}}
|
||||||
|
const response = await this.request({
|
||||||
|
path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}},
|
||||||
|
method: '{{httpMethod}}',
|
||||||
|
headers: headerParameters,
|
||||||
|
{{#hasQueryParams}}
|
||||||
|
query: queryParameters,
|
||||||
|
{{/hasQueryParams}}
|
||||||
|
{{#hasBodyParam}}
|
||||||
|
{{#bodyParam}}
|
||||||
|
{{#isContainer}}
|
||||||
|
body: requestParameters.{{paramName}}.map({{#items}}{{datatype}}{{/items}}ToJSON),
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
{{^isPrimitiveType}}
|
||||||
|
body: {{dataType}}ToJSON(requestParameters.{{paramName}}),
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{#isPrimitiveType}}
|
||||||
|
body: requestParameters.{{paramName}} as any,
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/bodyParam}}
|
||||||
|
{{/hasBodyParam}}
|
||||||
|
{{#hasFormParams}}
|
||||||
|
body: formData,
|
||||||
|
{{/hasFormParams}}
|
||||||
|
});
|
||||||
|
|
||||||
|
{{#returnType}}
|
||||||
|
{{#isResponseFile}}
|
||||||
|
return new runtime.BlobApiResponse(response);
|
||||||
|
{{/isResponseFile}}
|
||||||
|
{{^isResponseFile}}
|
||||||
|
{{#returnTypeIsPrimitive}}
|
||||||
|
{{#isMapContainer}}
|
||||||
|
return new runtime.JSONApiResponse<any>(response);
|
||||||
|
{{/isMapContainer}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
return new runtime.JSONApiResponse<any>(response);
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{#returnSimpleType}}
|
||||||
|
return new runtime.TextApiResponse(response);
|
||||||
|
{{/returnSimpleType}}
|
||||||
|
{{/returnTypeIsPrimitive}}
|
||||||
|
{{^returnTypeIsPrimitive}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map({{returnBaseType}}FromJSON));
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{^isListContainer}}
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => {{returnBaseType}}FromJSON(jsonValue));
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{/returnTypeIsPrimitive}}
|
||||||
|
{{/isResponseFile}}
|
||||||
|
{{/returnType}}
|
||||||
|
{{^returnType}}
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
{{/returnType}}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
{{#notes}}
|
||||||
|
* {{¬es}}
|
||||||
|
{{/notes}}
|
||||||
|
{{#summary}}
|
||||||
|
* {{&summary}}
|
||||||
|
{{/summary}}
|
||||||
|
*/
|
||||||
|
async {{nickname}}({{#allParams.0}}requestParameters: {{operationIdCamelCase}}Request{{/allParams.0}}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
||||||
|
{{#returnType}}
|
||||||
|
const response = await this.{{nickname}}Raw({{#allParams.0}}requestParameters{{/allParams.0}});
|
||||||
|
return await response.value();
|
||||||
|
{{/returnType}}
|
||||||
|
{{^returnType}}
|
||||||
|
await this.{{nickname}}Raw({{#allParams.0}}requestParameters{{/allParams.0}});
|
||||||
|
{{/returnType}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
@ -1,63 +0,0 @@
|
|||||||
// tslint:disable
|
|
||||||
{{>licenseInfo}}
|
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
username?: string;
|
|
||||||
password?: string;
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
basePath?: string;
|
|
||||||
baseOptions?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Configuration {
|
|
||||||
/**
|
|
||||||
* parameter for apiKey security
|
|
||||||
* @param name security name
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
username?: string;
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
password?: string;
|
|
||||||
/**
|
|
||||||
* parameter for oauth2 security
|
|
||||||
* @param name security name
|
|
||||||
* @param scopes oauth2 scope
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
/**
|
|
||||||
* override base path
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
basePath?: string;
|
|
||||||
/**
|
|
||||||
* base options for fetch calls
|
|
||||||
*
|
|
||||||
* @type {any}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
baseOptions?: any;
|
|
||||||
|
|
||||||
constructor(param: ConfigurationParameters = {}) {
|
|
||||||
this.apiKey = param.apiKey;
|
|
||||||
this.username = param.username;
|
|
||||||
this.password = param.password;
|
|
||||||
this.accessToken = param.accessToken;
|
|
||||||
this.basePath = param.basePath;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
declare module 'portable-fetch';
|
|
||||||
declare module 'url';
|
|
@ -1,51 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
|
||||||
#
|
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
|
||||||
|
|
||||||
git_user_id=$1
|
|
||||||
git_repo_id=$2
|
|
||||||
release_note=$3
|
|
||||||
|
|
||||||
if [ "$git_user_id" = "" ]; then
|
|
||||||
git_user_id="{{{gitUserId}}}"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_repo_id" = "" ]; then
|
|
||||||
git_repo_id="{{{gitRepoId}}}"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$release_note" = "" ]; then
|
|
||||||
release_note="{{{releaseNote}}}"
|
|
||||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize the local directory as a Git repository
|
|
||||||
git init
|
|
||||||
|
|
||||||
# Adds the files in the local repository and stages them for commit.
|
|
||||||
git add .
|
|
||||||
|
|
||||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
|
||||||
git commit -m "$release_note"
|
|
||||||
|
|
||||||
# Sets the new remote
|
|
||||||
git_remote=`git remote`
|
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
else
|
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
git pull origin master
|
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
|
||||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
|
@ -1,3 +0,0 @@
|
|||||||
wwwroot/*.js
|
|
||||||
node_modules
|
|
||||||
typings
|
|
@ -1,5 +1,3 @@
|
|||||||
// tslint:disable
|
export * from './runtime';
|
||||||
{{>licenseInfo}}
|
export * from './apis';
|
||||||
|
export * from './models';
|
||||||
export * from "./api";
|
|
||||||
export * from "./configuration";
|
|
||||||
|
@ -10,3 +10,11 @@ export enum {{classname}} {
|
|||||||
{{/enumVars}}
|
{{/enumVars}}
|
||||||
{{/allowableValues}}
|
{{/allowableValues}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function {{classname}}FromJSON(json: any): {{classname}} {
|
||||||
|
return json as {{classname}};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function {{classname}}ToJSON(value?: {{classname}}): any {
|
||||||
|
return value as any;
|
||||||
|
}
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
import { exists } from '../runtime';
|
||||||
|
{{#hasImports}}
|
||||||
|
import {
|
||||||
|
{{#imports}}
|
||||||
|
{{{.}}},
|
||||||
|
{{.}}FromJSON,
|
||||||
|
{{.}}ToJSON,
|
||||||
|
{{/imports}}
|
||||||
|
} from './';
|
||||||
|
|
||||||
|
{{/hasImports}}
|
||||||
/**
|
/**
|
||||||
* {{{description}}}
|
* {{{description}}}
|
||||||
* @export
|
* @export
|
||||||
@ -6,7 +17,6 @@
|
|||||||
export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
||||||
{{#additionalPropertiesType}}
|
{{#additionalPropertiesType}}
|
||||||
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
||||||
|
|
||||||
{{/additionalPropertiesType}}
|
{{/additionalPropertiesType}}
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
/**
|
/**
|
||||||
@ -14,9 +24,69 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
|||||||
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
||||||
* @memberof {{classname}}
|
* @memberof {{classname}}
|
||||||
*/
|
*/
|
||||||
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}};
|
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}{{#hasEnums}}
|
}
|
||||||
|
|
||||||
|
export function {{classname}}FromJSON(json: any): {{classname}} {
|
||||||
|
{{#hasVars}}
|
||||||
|
return {
|
||||||
|
{{#vars}}
|
||||||
|
{{#isPrimitiveType}}
|
||||||
|
{{#isDate}}
|
||||||
|
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}new Date(json['{{baseName}}']),
|
||||||
|
{{/isDate}}
|
||||||
|
{{#isDateTime}}
|
||||||
|
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}new Date(json['{{baseName}}']),
|
||||||
|
{{/isDateTime}}
|
||||||
|
{{^isDate}}
|
||||||
|
{{^isDateTime}}
|
||||||
|
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}json['{{baseName}}'],
|
||||||
|
{{/isDateTime}}
|
||||||
|
{{/isDate}}
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{^isPrimitiveType}}
|
||||||
|
{{#isContainer}}
|
||||||
|
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}(json['{{baseName}}'] as Array<any>).map({{#items}}{{datatype}}{{/items}}FromJSON),
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}{{datatype}}FromJSON(json['{{baseName}}']),
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{/vars}}
|
||||||
|
};
|
||||||
|
{{/hasVars}}
|
||||||
|
{{^hasVars}}
|
||||||
|
return json;
|
||||||
|
{{/hasVars}}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function {{classname}}ToJSON(value?: {{classname}}): any {
|
||||||
|
{{#hasVars}}
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
{{#vars}}
|
||||||
|
{{#isPrimitiveType}}
|
||||||
|
'{{baseName}}': {{#isDate}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString(){{/isDate}}{{#isDateTime}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString(){{/isDateTime}}{{^isDate}}{{^isDateTime}}value.{{name}}{{/isDateTime}}{{/isDate}},
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{^isPrimitiveType}}
|
||||||
|
{{#isContainer}}
|
||||||
|
'{{baseName}}': (value.{{name}} as Array<any>).map({{#items}}{{datatype}}{{/items}}ToJSON),
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
'{{baseName}}': {{datatype}}ToJSON(value.{{name}}),
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{/vars}}
|
||||||
|
};
|
||||||
|
{{/hasVars}}
|
||||||
|
{{^hasVars}}
|
||||||
|
return value;
|
||||||
|
{{/hasVars}}
|
||||||
|
}
|
||||||
|
{{#hasEnums}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
export * from './{{{ classFilename }}}';
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
@ -0,0 +1,12 @@
|
|||||||
|
// tslint:disable
|
||||||
|
{{>licenseInfo}}
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
{{#isEnum}}
|
||||||
|
{{>modelEnum}}
|
||||||
|
{{/isEnum}}
|
||||||
|
{{^isEnum}}
|
||||||
|
{{>modelGeneric}}
|
||||||
|
{{/isEnum}}
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
@ -2,26 +2,14 @@
|
|||||||
"name": "{{npmName}}",
|
"name": "{{npmName}}",
|
||||||
"version": "{{npmVersion}}",
|
"version": "{{npmVersion}}",
|
||||||
"description": "OpenAPI client for {{npmName}}",
|
"description": "OpenAPI client for {{npmName}}",
|
||||||
"author": "OpenAPI-Generator Contributors",
|
"author": "OpenAPI-Generator",
|
||||||
"keywords": [
|
|
||||||
"fetch",
|
|
||||||
"typescript",
|
|
||||||
"openapi-client",
|
|
||||||
"openapi-generator",
|
|
||||||
"{{npmName}}"
|
|
||||||
],
|
|
||||||
"license": "Unlicense",
|
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts" : {
|
"scripts" : {
|
||||||
"build": "tsc --outDir dist/",
|
"build": "tsc --outDir dist/",
|
||||||
"prepublishOnly": "npm run build"
|
"prepare": "npm run build"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"portable-fetch": "^3.0.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^8.0.9",
|
|
||||||
"typescript": "^2.4"
|
"typescript": "^2.4"
|
||||||
}{{#npmRepository}},{{/npmRepository}}
|
}{{#npmRepository}},{{/npmRepository}}
|
||||||
{{#npmRepository}}
|
{{#npmRepository}}
|
||||||
|
@ -0,0 +1,256 @@
|
|||||||
|
// tslint:disable
|
||||||
|
{{>licenseInfo}}
|
||||||
|
|
||||||
|
export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the base class for all generated API classes.
|
||||||
|
*/
|
||||||
|
export class BaseAPI {
|
||||||
|
|
||||||
|
private middleware: Middleware[];
|
||||||
|
|
||||||
|
constructor(protected configuration = new Configuration()) {
|
||||||
|
this.middleware = configuration.middleware;
|
||||||
|
}
|
||||||
|
|
||||||
|
withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
|
||||||
|
const next = this.clone<T>();
|
||||||
|
next.middleware = next.middleware.concat(...middlewares);
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
|
||||||
|
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
|
||||||
|
const middlewares = postMiddlewares.map((post) => ({ post }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async request(context: RequestOpts): Promise<Response> {
|
||||||
|
const { url, init } = this.createFetchParams(context);
|
||||||
|
const response = await this.fetchApi(url, init);
|
||||||
|
if (response.status >= 200 && response.status < 300) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
throw response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private createFetchParams(context: RequestOpts) {
|
||||||
|
let url = this.configuration.basePath + context.path;
|
||||||
|
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
||||||
|
// only add the querystring to the URL if there are query parameters.
|
||||||
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
|
// do not handle correctly sometimes.
|
||||||
|
url += '?' + querystring(context.query);
|
||||||
|
}
|
||||||
|
const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body);
|
||||||
|
const init = {
|
||||||
|
method: context.method,
|
||||||
|
headers: context.headers,
|
||||||
|
body,
|
||||||
|
};
|
||||||
|
return { url, init };
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchApi = async (url: string, init: RequestInit) => {
|
||||||
|
let fetchParams = { url, init };
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.pre) {
|
||||||
|
fetchParams = await middleware.pre({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
...fetchParams,
|
||||||
|
}) || fetchParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.post) {
|
||||||
|
response = await middleware.post({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
url,
|
||||||
|
init,
|
||||||
|
response: response.clone(),
|
||||||
|
}) || response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a shallow clone of `this` by constructing a new instance
|
||||||
|
* and then shallow cloning data members.
|
||||||
|
*/
|
||||||
|
private clone<T extends BaseAPI>(this: T): T {
|
||||||
|
const constructor = this.constructor as any;
|
||||||
|
const next = new constructor(this.configuration);
|
||||||
|
next.middleware = this.middleware.slice();
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export class RequiredError extends Error {
|
||||||
|
name: "RequiredError" = "RequiredError";
|
||||||
|
constructor(public field: string, msg?: string) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
csv: ",",
|
||||||
|
ssv: " ",
|
||||||
|
tsv: "\t",
|
||||||
|
pipes: "|",
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FetchAPI = GlobalFetch['fetch'];
|
||||||
|
|
||||||
|
export interface ConfigurationParameters {
|
||||||
|
basePath?: string; // override base path
|
||||||
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
username?: string; // parameter for basic security
|
||||||
|
password?: string; // parameter for basic security
|
||||||
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
|
accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Configuration {
|
||||||
|
constructor(private configuration: ConfigurationParameters = {}) {}
|
||||||
|
|
||||||
|
get basePath(): string {
|
||||||
|
return this.configuration.basePath || BASE_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
get fetchApi(): FetchAPI {
|
||||||
|
return this.configuration.fetchApi || window.fetch.bind(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
get middleware(): Middleware[] {
|
||||||
|
return this.configuration.middleware || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get username(): string | undefined {
|
||||||
|
return this.configuration.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
get password(): string | undefined {
|
||||||
|
return this.configuration.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
get apiKey(): ((name: string) => string) | undefined {
|
||||||
|
const apiKey = this.configuration.apiKey;
|
||||||
|
if (apiKey) {
|
||||||
|
return typeof apiKey === 'function' ? apiKey : () => apiKey;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||||
|
const accessToken = this.configuration.accessToken;
|
||||||
|
if (accessToken) {
|
||||||
|
return typeof accessToken === 'function' ? accessToken : () => accessToken;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Json = any;
|
||||||
|
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
||||||
|
export type HTTPHeaders = { [key: string]: string };
|
||||||
|
export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> };
|
||||||
|
export type HTTPBody = Json | FormData;
|
||||||
|
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
|
||||||
|
|
||||||
|
export interface FetchParams {
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestOpts {
|
||||||
|
path: string;
|
||||||
|
method: HTTPMethod;
|
||||||
|
headers: HTTPHeaders;
|
||||||
|
query?: HTTPQuery;
|
||||||
|
body?: HTTPBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exists(json: any, key: string) {
|
||||||
|
const value = json[key];
|
||||||
|
return value !== null && value !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function querystring(params: HTTPQuery) {
|
||||||
|
return Object.keys(params)
|
||||||
|
.map((key) => {
|
||||||
|
const value = params[key];
|
||||||
|
if (value instanceof Array) {
|
||||||
|
const multiValue = value.join(`&${encodeURIComponent(key)}=`);
|
||||||
|
return `${encodeURIComponent(key)}=${multiValue}`;
|
||||||
|
}
|
||||||
|
return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
||||||
|
})
|
||||||
|
.join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
response: Response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Middleware {
|
||||||
|
pre?(context: RequestContext): Promise<FetchParams | void>;
|
||||||
|
post?(context: ResponseContext): Promise<Response | void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiResponse<T> {
|
||||||
|
raw: Response;
|
||||||
|
value(): Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseTransformer<T> {
|
||||||
|
(json: any): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class JSONApiResponse<T> {
|
||||||
|
constructor(public raw: Response, private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return this.transformer(await this.raw.json());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class VoidApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BlobApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.blob();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TextApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.text();
|
||||||
|
};
|
||||||
|
}
|
@ -3,7 +3,6 @@
|
|||||||
"declaration": true,
|
"declaration": true,
|
||||||
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
|
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"noImplicitAny": true,
|
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"rootDir": "."{{^supportsES6}},
|
"rootDir": "."{{^supportsES6}},
|
||||||
"lib": [
|
"lib": [
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
wwwroot/*.js
|
|
||||||
node_modules
|
|
||||||
typings
|
|
@ -13,70 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import * as url from "url";
|
export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");
|
||||||
import * as portableFetch from "portable-fetch";
|
|
||||||
import { Configuration } from "./configuration";
|
|
||||||
|
|
||||||
const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
*/
|
|
||||||
export const COLLECTION_FORMATS = {
|
|
||||||
csv: ",",
|
|
||||||
ssv: " ",
|
|
||||||
tsv: "\t",
|
|
||||||
pipes: "|",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface FetchAPI
|
|
||||||
*/
|
|
||||||
export interface FetchAPI {
|
|
||||||
(url: string, init?: any): Promise<Response>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface FetchArgs
|
|
||||||
*/
|
|
||||||
export interface FetchArgs {
|
|
||||||
url: string;
|
|
||||||
options: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @class BaseAPI
|
|
||||||
*/
|
|
||||||
export class BaseAPI {
|
|
||||||
protected configuration: Configuration | undefined;
|
|
||||||
|
|
||||||
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) {
|
|
||||||
if (configuration) {
|
|
||||||
this.configuration = configuration;
|
|
||||||
this.basePath = configuration.basePath || this.basePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @class RequiredError
|
|
||||||
* @extends {Error}
|
|
||||||
*/
|
|
||||||
export class RequiredError extends Error {
|
|
||||||
name: "RequiredError" = "RequiredError";
|
|
||||||
constructor(public field: string, msg?: string) {
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the result of uploading an image resource
|
* Describes the result of uploading an image resource
|
||||||
@ -341,11 +278,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/pet`;
|
const localVarPath = `/pet`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -388,11 +321,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
const localVarPath = `/pet/{petId}`
|
const localVarPath = `/pet/{petId}`
|
||||||
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -433,11 +362,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/pet/findByStatus`;
|
const localVarPath = `/pet/findByStatus`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -478,11 +403,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/pet/findByTags`;
|
const localVarPath = `/pet/findByTags`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -524,11 +445,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
const localVarPath = `/pet/{petId}`
|
const localVarPath = `/pet/{petId}`
|
||||||
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -564,11 +481,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/pet`;
|
const localVarPath = `/pet`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'PUT' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -612,11 +525,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
const localVarPath = `/pet/{petId}`
|
const localVarPath = `/pet/{petId}`
|
||||||
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
const localVarFormParams = new url.URLSearchParams();
|
const localVarFormParams = new url.URLSearchParams();
|
||||||
@ -668,11 +577,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
const localVarPath = `/pet/{petId}/uploadImage`
|
const localVarPath = `/pet/{petId}/uploadImage`
|
||||||
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
.replace(`{${"petId"}}`, encodeURIComponent(String(petId)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
const localVarFormParams = new url.URLSearchParams();
|
const localVarFormParams = new url.URLSearchParams();
|
||||||
@ -1101,11 +1006,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration
|
|||||||
const localVarPath = `/store/order/{orderId}`
|
const localVarPath = `/store/order/{orderId}`
|
||||||
.replace(`{${"orderId"}}`, encodeURIComponent(String(orderId)));
|
.replace(`{${"orderId"}}`, encodeURIComponent(String(orderId)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1128,11 +1029,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration
|
|||||||
getInventory(options: any = {}): FetchArgs {
|
getInventory(options: any = {}): FetchArgs {
|
||||||
const localVarPath = `/store/inventory`;
|
const localVarPath = `/store/inventory`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1169,11 +1066,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration
|
|||||||
const localVarPath = `/store/order/{orderId}`
|
const localVarPath = `/store/order/{orderId}`
|
||||||
.replace(`{${"orderId"}}`, encodeURIComponent(String(orderId)));
|
.replace(`{${"orderId"}}`, encodeURIComponent(String(orderId)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1201,11 +1094,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration
|
|||||||
}
|
}
|
||||||
const localVarPath = `/store/order`;
|
const localVarPath = `/store/order`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1434,11 +1323,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/user`;
|
const localVarPath = `/user`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1470,11 +1355,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/user/createWithArray`;
|
const localVarPath = `/user/createWithArray`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1506,11 +1387,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/user/createWithList`;
|
const localVarPath = `/user/createWithList`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'POST' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1543,11 +1420,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
const localVarPath = `/user/{username}`
|
const localVarPath = `/user/{username}`
|
||||||
.replace(`{${"username"}}`, encodeURIComponent(String(username)));
|
.replace(`{${"username"}}`, encodeURIComponent(String(username)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1576,11 +1449,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
const localVarPath = `/user/{username}`
|
const localVarPath = `/user/{username}`
|
||||||
.replace(`{${"username"}}`, encodeURIComponent(String(username)));
|
.replace(`{${"username"}}`, encodeURIComponent(String(username)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1613,11 +1482,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
}
|
}
|
||||||
const localVarPath = `/user/login`;
|
const localVarPath = `/user/login`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1648,11 +1513,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
logoutUser(options: any = {}): FetchArgs {
|
logoutUser(options: any = {}): FetchArgs {
|
||||||
const localVarPath = `/user/logout`;
|
const localVarPath = `/user/logout`;
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'GET' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
@ -1686,11 +1547,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
const localVarPath = `/user/{username}`
|
const localVarPath = `/user/{username}`
|
||||||
.replace(`{${"username"}}`, encodeURIComponent(String(username)));
|
.replace(`{${"username"}}`, encodeURIComponent(String(username)));
|
||||||
const localVarUrlObj = url.parse(localVarPath, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
let baseOptions;
|
const localVarRequestOptions = Object.assign({ method: 'PUT' }, options);
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions = Object.assign({ method: 'PUT' }, baseOptions, options);
|
|
||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
@ -0,0 +1,396 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
ModelApiResponse,
|
||||||
|
ModelApiResponseFromJSON,
|
||||||
|
ModelApiResponseToJSON,
|
||||||
|
Pet,
|
||||||
|
PetFromJSON,
|
||||||
|
PetToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface AddPetRequest {
|
||||||
|
pet: Pet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeletePetRequest {
|
||||||
|
petId: number;
|
||||||
|
apiKey?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FindPetsByStatusRequest {
|
||||||
|
status: Array<'available' | 'pending' | 'sold'>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FindPetsByTagsRequest {
|
||||||
|
tags: Array<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetPetByIdRequest {
|
||||||
|
petId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdatePetRequest {
|
||||||
|
pet: Pet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdatePetWithFormRequest {
|
||||||
|
petId: number;
|
||||||
|
name?: string;
|
||||||
|
status?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UploadFileRequest {
|
||||||
|
petId: number;
|
||||||
|
additionalMetadata?: string;
|
||||||
|
file?: Blob;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*/
|
||||||
|
async addPetRaw(requestParameters: AddPetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.pet === null || requestParameters.pet === undefined) {
|
||||||
|
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: PetToJSON(requestParameters.pet),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*/
|
||||||
|
async addPet(requestParameters: AddPetRequest): Promise<void> {
|
||||||
|
await this.addPetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*/
|
||||||
|
async deletePetRaw(requestParameters: DeletePetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) {
|
||||||
|
headerParameters['api_key'] = String(requestParameters.apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*/
|
||||||
|
async deletePet(requestParameters: DeletePetRequest): Promise<void> {
|
||||||
|
await this.deletePetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
*/
|
||||||
|
async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Promise<runtime.ApiResponse<Array<Pet>>> {
|
||||||
|
if (requestParameters.status === null || requestParameters.status === undefined) {
|
||||||
|
throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.status) {
|
||||||
|
queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/findByStatus`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
*/
|
||||||
|
async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise<Array<Pet>> {
|
||||||
|
const response = await this.findPetsByStatusRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
*/
|
||||||
|
async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Promise<runtime.ApiResponse<Array<Pet>>> {
|
||||||
|
if (requestParameters.tags === null || requestParameters.tags === undefined) {
|
||||||
|
throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.tags) {
|
||||||
|
queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/findByTags`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
*/
|
||||||
|
async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise<Array<Pet>> {
|
||||||
|
const response = await this.findPetsByTagsRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
*/
|
||||||
|
async getPetByIdRaw(requestParameters: GetPetByIdRequest): Promise<runtime.ApiResponse<Pet>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
*/
|
||||||
|
async getPetById(requestParameters: GetPetByIdRequest): Promise<Pet> {
|
||||||
|
const response = await this.getPetByIdRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*/
|
||||||
|
async updatePetRaw(requestParameters: UpdatePetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.pet === null || requestParameters.pet === undefined) {
|
||||||
|
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet`,
|
||||||
|
method: 'PUT',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: PetToJSON(requestParameters.pet),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*/
|
||||||
|
async updatePet(requestParameters: UpdatePetRequest): Promise<void> {
|
||||||
|
await this.updatePetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*/
|
||||||
|
async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
if (requestParameters.name !== undefined) {
|
||||||
|
formData.append('name', requestParameters.name as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.status !== undefined) {
|
||||||
|
formData.append('status', requestParameters.status as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*/
|
||||||
|
async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise<void> {
|
||||||
|
await this.updatePetWithFormRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*/
|
||||||
|
async uploadFileRaw(requestParameters: UploadFileRequest): Promise<runtime.ApiResponse<ModelApiResponse>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
if (requestParameters.additionalMetadata !== undefined) {
|
||||||
|
formData.append('additionalMetadata', requestParameters.additionalMetadata as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.file !== undefined) {
|
||||||
|
formData.append('file', requestParameters.file as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*/
|
||||||
|
async uploadFile(requestParameters: UploadFileRequest): Promise<ModelApiResponse> {
|
||||||
|
const response = await this.uploadFileRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
Order,
|
||||||
|
OrderFromJSON,
|
||||||
|
OrderToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface DeleteOrderRequest {
|
||||||
|
orderId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetOrderByIdRequest {
|
||||||
|
orderId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlaceOrderRequest {
|
||||||
|
order: Order;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
*/
|
||||||
|
async deleteOrderRaw(requestParameters: DeleteOrderRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.orderId === null || requestParameters.orderId === undefined) {
|
||||||
|
throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
*/
|
||||||
|
async deleteOrder(requestParameters: DeleteOrderRequest): Promise<void> {
|
||||||
|
await this.deleteOrderRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
async getInventoryRaw(): Promise<runtime.ApiResponse<{ [key: string]: number; }>> {
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/inventory`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse<any>(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
async getInventory(): Promise<{ [key: string]: number; }> {
|
||||||
|
const response = await this.getInventoryRaw();
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
*/
|
||||||
|
async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise<runtime.ApiResponse<Order>> {
|
||||||
|
if (requestParameters.orderId === null || requestParameters.orderId === undefined) {
|
||||||
|
throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
*/
|
||||||
|
async getOrderById(requestParameters: GetOrderByIdRequest): Promise<Order> {
|
||||||
|
const response = await this.getOrderByIdRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*/
|
||||||
|
async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise<runtime.ApiResponse<Order>> {
|
||||||
|
if (requestParameters.order === null || requestParameters.order === undefined) {
|
||||||
|
throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: OrderToJSON(requestParameters.order),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*/
|
||||||
|
async placeOrder(requestParameters: PlaceOrderRequest): Promise<Order> {
|
||||||
|
const response = await this.placeOrderRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,300 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
User,
|
||||||
|
UserFromJSON,
|
||||||
|
UserToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface CreateUserRequest {
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUsersWithArrayInputRequest {
|
||||||
|
user: Array<User>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUsersWithListInputRequest {
|
||||||
|
user: Array<User>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteUserRequest {
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetUserByNameRequest {
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginUserRequest {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateUserRequest {
|
||||||
|
username: string;
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
*/
|
||||||
|
async createUserRaw(requestParameters: CreateUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: UserToJSON(requestParameters.user),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
*/
|
||||||
|
async createUser(requestParameters: CreateUserRequest): Promise<void> {
|
||||||
|
await this.createUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/createWithArray`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: requestParameters.user.map(UserToJSON),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise<void> {
|
||||||
|
await this.createUsersWithArrayInputRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/createWithList`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: requestParameters.user.map(UserToJSON),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise<void> {
|
||||||
|
await this.createUsersWithListInputRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
*/
|
||||||
|
async deleteUserRaw(requestParameters: DeleteUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
*/
|
||||||
|
async deleteUser(requestParameters: DeleteUserRequest): Promise<void> {
|
||||||
|
await this.deleteUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*/
|
||||||
|
async getUserByNameRaw(requestParameters: GetUserByNameRequest): Promise<runtime.ApiResponse<User>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*/
|
||||||
|
async getUserByName(requestParameters: GetUserByNameRequest): Promise<User> {
|
||||||
|
const response = await this.getUserByNameRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*/
|
||||||
|
async loginUserRaw(requestParameters: LoginUserRequest): Promise<runtime.ApiResponse<string>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.password === null || requestParameters.password === undefined) {
|
||||||
|
throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.username !== undefined) {
|
||||||
|
queryParameters['username'] = requestParameters.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.password !== undefined) {
|
||||||
|
queryParameters['password'] = requestParameters.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/login`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.TextApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*/
|
||||||
|
async loginUser(requestParameters: LoginUserRequest): Promise<string> {
|
||||||
|
const response = await this.loginUserRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
async logoutUserRaw(): Promise<runtime.ApiResponse<void>> {
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/logout`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
async logoutUser(): Promise<void> {
|
||||||
|
await this.logoutUserRaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
*/
|
||||||
|
async updateUserRaw(requestParameters: UpdateUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'PUT',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: UserToJSON(requestParameters.user),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
*/
|
||||||
|
async updateUser(requestParameters: UpdateUserRequest): Promise<void> {
|
||||||
|
await this.updateUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
export * from './PetApi';
|
||||||
|
export * from './StoreApi';
|
||||||
|
export * from './UserApi';
|
@ -1,74 +0,0 @@
|
|||||||
// tslint:disable
|
|
||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
username?: string;
|
|
||||||
password?: string;
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
basePath?: string;
|
|
||||||
baseOptions?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Configuration {
|
|
||||||
/**
|
|
||||||
* parameter for apiKey security
|
|
||||||
* @param name security name
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
username?: string;
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
password?: string;
|
|
||||||
/**
|
|
||||||
* parameter for oauth2 security
|
|
||||||
* @param name security name
|
|
||||||
* @param scopes oauth2 scope
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
/**
|
|
||||||
* override base path
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
basePath?: string;
|
|
||||||
/**
|
|
||||||
* base options for fetch calls
|
|
||||||
*
|
|
||||||
* @type {any}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
baseOptions?: any;
|
|
||||||
|
|
||||||
constructor(param: ConfigurationParameters = {}) {
|
|
||||||
this.apiKey = param.apiKey;
|
|
||||||
this.username = param.username;
|
|
||||||
this.password = param.password;
|
|
||||||
this.accessToken = param.accessToken;
|
|
||||||
this.basePath = param.basePath;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
declare module 'portable-fetch';
|
|
||||||
declare module 'url';
|
|
@ -1,51 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
|
||||||
#
|
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
|
||||||
|
|
||||||
git_user_id=$1
|
|
||||||
git_repo_id=$2
|
|
||||||
release_note=$3
|
|
||||||
|
|
||||||
if [ "$git_user_id" = "" ]; then
|
|
||||||
git_user_id="GIT_USER_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_repo_id" = "" ]; then
|
|
||||||
git_repo_id="GIT_REPO_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$release_note" = "" ]; then
|
|
||||||
release_note="Minor update"
|
|
||||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize the local directory as a Git repository
|
|
||||||
git init
|
|
||||||
|
|
||||||
# Adds the files in the local repository and stages them for commit.
|
|
||||||
git add .
|
|
||||||
|
|
||||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
|
||||||
git commit -m "$release_note"
|
|
||||||
|
|
||||||
# Sets the new remote
|
|
||||||
git_remote=`git remote`
|
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
else
|
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
git pull origin master
|
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
|
||||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
|
@ -1,16 +1,3 @@
|
|||||||
// tslint:disable
|
export * from './runtime';
|
||||||
/**
|
export * from './apis';
|
||||||
* OpenAPI Petstore
|
export * from './models';
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export * from "./api";
|
|
||||||
export * from "./configuration";
|
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
* @export
|
||||||
|
* @interface ApiResponse
|
||||||
|
*/
|
||||||
|
export interface ApiResponse {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
code?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
type?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiResponseFromJSON(json: any): ApiResponse {
|
||||||
|
return {
|
||||||
|
'code': !exists(json, 'code') ? undefined : json['code'],
|
||||||
|
'type': !exists(json, 'type') ? undefined : json['type'],
|
||||||
|
'message': !exists(json, 'message') ? undefined : json['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiResponseToJSON(value?: ApiResponse): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'code': value.code,
|
||||||
|
'type': value.type,
|
||||||
|
'message': value.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
* @export
|
||||||
|
* @interface Category
|
||||||
|
*/
|
||||||
|
export interface Category {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Category
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Category
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CategoryFromJSON(json: any): Category {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'name': !exists(json, 'name') ? undefined : json['name'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CategoryToJSON(value?: Category): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'name': value.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
* @export
|
||||||
|
* @interface ModelApiResponse
|
||||||
|
*/
|
||||||
|
export interface ModelApiResponse {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
code?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
type?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ModelApiResponseFromJSON(json: any): ModelApiResponse {
|
||||||
|
return {
|
||||||
|
'code': !exists(json, 'code') ? undefined : json['code'],
|
||||||
|
'type': !exists(json, 'type') ? undefined : json['type'],
|
||||||
|
'message': !exists(json, 'message') ? undefined : json['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ModelApiResponseToJSON(value?: ModelApiResponse): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'code': value.code,
|
||||||
|
'type': value.type,
|
||||||
|
'message': value.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,99 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
* @export
|
||||||
|
* @interface Order
|
||||||
|
*/
|
||||||
|
export interface Order {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
petId?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
quantity?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Date}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
shipDate?: Date;
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
status?: Order.StatusEnum;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
complete?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OrderFromJSON(json: any): Order {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'petId': !exists(json, 'petId') ? undefined : json['petId'],
|
||||||
|
'quantity': !exists(json, 'quantity') ? undefined : json['quantity'],
|
||||||
|
'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']),
|
||||||
|
'status': !exists(json, 'status') ? undefined : json['status'],
|
||||||
|
'complete': !exists(json, 'complete') ? undefined : json['complete'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OrderToJSON(value?: Order): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'petId': value.petId,
|
||||||
|
'quantity': value.quantity,
|
||||||
|
'shipDate': value.shipDate === undefined ? undefined : value.shipDate.toISOString(),
|
||||||
|
'status': value.status,
|
||||||
|
'complete': value.complete,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @namespace Order
|
||||||
|
*/
|
||||||
|
export namespace Order {
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum StatusEnum {
|
||||||
|
Placed = 'placed',
|
||||||
|
Approved = 'approved',
|
||||||
|
Delivered = 'delivered'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
import {
|
||||||
|
Category,
|
||||||
|
CategoryFromJSON,
|
||||||
|
CategoryToJSON,
|
||||||
|
Tag,
|
||||||
|
TagFromJSON,
|
||||||
|
TagToJSON,
|
||||||
|
} from './';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
* @export
|
||||||
|
* @interface Pet
|
||||||
|
*/
|
||||||
|
export interface Pet {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Category}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
category?: Category;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Array<string>}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
photoUrls: Array<string>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Array<Tag>}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
tags?: Array<Tag>;
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
status?: Pet.StatusEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PetFromJSON(json: any): Pet {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']),
|
||||||
|
'name': json['name'],
|
||||||
|
'photoUrls': json['photoUrls'],
|
||||||
|
'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array<any>).map(TagFromJSON),
|
||||||
|
'status': !exists(json, 'status') ? undefined : json['status'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PetToJSON(value?: Pet): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'category': CategoryToJSON(value.category),
|
||||||
|
'name': value.name,
|
||||||
|
'photoUrls': value.photoUrls,
|
||||||
|
'tags': (value.tags as Array<any>).map(TagToJSON),
|
||||||
|
'status': value.status,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @namespace Pet
|
||||||
|
*/
|
||||||
|
export namespace Pet {
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum StatusEnum {
|
||||||
|
Available = 'available',
|
||||||
|
Pending = 'pending',
|
||||||
|
Sold = 'sold'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
* @export
|
||||||
|
* @interface Tag
|
||||||
|
*/
|
||||||
|
export interface Tag {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Tag
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Tag
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TagFromJSON(json: any): Tag {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'name': !exists(json, 'name') ? undefined : json['name'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TagToJSON(value?: Tag): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'name': value.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
* @export
|
||||||
|
* @interface User
|
||||||
|
*/
|
||||||
|
export interface User {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
username?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
firstName?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
lastName?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
email?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
password?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
phone?: string;
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
* @type {number}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
userStatus?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserFromJSON(json: any): User {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'username': !exists(json, 'username') ? undefined : json['username'],
|
||||||
|
'firstName': !exists(json, 'firstName') ? undefined : json['firstName'],
|
||||||
|
'lastName': !exists(json, 'lastName') ? undefined : json['lastName'],
|
||||||
|
'email': !exists(json, 'email') ? undefined : json['email'],
|
||||||
|
'password': !exists(json, 'password') ? undefined : json['password'],
|
||||||
|
'phone': !exists(json, 'phone') ? undefined : json['phone'],
|
||||||
|
'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserToJSON(value?: User): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'username': value.username,
|
||||||
|
'firstName': value.firstName,
|
||||||
|
'lastName': value.lastName,
|
||||||
|
'email': value.email,
|
||||||
|
'password': value.password,
|
||||||
|
'phone': value.phone,
|
||||||
|
'userStatus': value.userStatus,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
export * from './Category';
|
||||||
|
export * from './ModelApiResponse';
|
||||||
|
export * from './Order';
|
||||||
|
export * from './Pet';
|
||||||
|
export * from './Tag';
|
||||||
|
export * from './User';
|
@ -0,0 +1,267 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the base class for all generated API classes.
|
||||||
|
*/
|
||||||
|
export class BaseAPI {
|
||||||
|
|
||||||
|
private middleware: Middleware[];
|
||||||
|
|
||||||
|
constructor(protected configuration = new Configuration()) {
|
||||||
|
this.middleware = configuration.middleware;
|
||||||
|
}
|
||||||
|
|
||||||
|
withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
|
||||||
|
const next = this.clone<T>();
|
||||||
|
next.middleware = next.middleware.concat(...middlewares);
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
|
||||||
|
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
|
||||||
|
const middlewares = postMiddlewares.map((post) => ({ post }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async request(context: RequestOpts): Promise<Response> {
|
||||||
|
const { url, init } = this.createFetchParams(context);
|
||||||
|
const response = await this.fetchApi(url, init);
|
||||||
|
if (response.status >= 200 && response.status < 300) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
throw response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private createFetchParams(context: RequestOpts) {
|
||||||
|
let url = this.configuration.basePath + context.path;
|
||||||
|
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
||||||
|
// only add the querystring to the URL if there are query parameters.
|
||||||
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
|
// do not handle correctly sometimes.
|
||||||
|
url += '?' + querystring(context.query);
|
||||||
|
}
|
||||||
|
const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body);
|
||||||
|
const init = {
|
||||||
|
method: context.method,
|
||||||
|
headers: context.headers,
|
||||||
|
body,
|
||||||
|
};
|
||||||
|
return { url, init };
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchApi = async (url: string, init: RequestInit) => {
|
||||||
|
let fetchParams = { url, init };
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.pre) {
|
||||||
|
fetchParams = await middleware.pre({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
...fetchParams,
|
||||||
|
}) || fetchParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.post) {
|
||||||
|
response = await middleware.post({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
url,
|
||||||
|
init,
|
||||||
|
response: response.clone(),
|
||||||
|
}) || response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a shallow clone of `this` by constructing a new instance
|
||||||
|
* and then shallow cloning data members.
|
||||||
|
*/
|
||||||
|
private clone<T extends BaseAPI>(this: T): T {
|
||||||
|
const constructor = this.constructor as any;
|
||||||
|
const next = new constructor(this.configuration);
|
||||||
|
next.middleware = this.middleware.slice();
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export class RequiredError extends Error {
|
||||||
|
name: "RequiredError" = "RequiredError";
|
||||||
|
constructor(public field: string, msg?: string) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
csv: ",",
|
||||||
|
ssv: " ",
|
||||||
|
tsv: "\t",
|
||||||
|
pipes: "|",
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FetchAPI = GlobalFetch['fetch'];
|
||||||
|
|
||||||
|
export interface ConfigurationParameters {
|
||||||
|
basePath?: string; // override base path
|
||||||
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
username?: string; // parameter for basic security
|
||||||
|
password?: string; // parameter for basic security
|
||||||
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
|
accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Configuration {
|
||||||
|
constructor(private configuration: ConfigurationParameters = {}) {}
|
||||||
|
|
||||||
|
get basePath(): string {
|
||||||
|
return this.configuration.basePath || BASE_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
get fetchApi(): FetchAPI {
|
||||||
|
return this.configuration.fetchApi || window.fetch.bind(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
get middleware(): Middleware[] {
|
||||||
|
return this.configuration.middleware || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get username(): string | undefined {
|
||||||
|
return this.configuration.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
get password(): string | undefined {
|
||||||
|
return this.configuration.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
get apiKey(): ((name: string) => string) | undefined {
|
||||||
|
const apiKey = this.configuration.apiKey;
|
||||||
|
if (apiKey) {
|
||||||
|
return typeof apiKey === 'function' ? apiKey : () => apiKey;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||||
|
const accessToken = this.configuration.accessToken;
|
||||||
|
if (accessToken) {
|
||||||
|
return typeof accessToken === 'function' ? accessToken : () => accessToken;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Json = any;
|
||||||
|
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
||||||
|
export type HTTPHeaders = { [key: string]: string };
|
||||||
|
export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> };
|
||||||
|
export type HTTPBody = Json | FormData;
|
||||||
|
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
|
||||||
|
|
||||||
|
export interface FetchParams {
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestOpts {
|
||||||
|
path: string;
|
||||||
|
method: HTTPMethod;
|
||||||
|
headers: HTTPHeaders;
|
||||||
|
query?: HTTPQuery;
|
||||||
|
body?: HTTPBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exists(json: any, key: string) {
|
||||||
|
const value = json[key];
|
||||||
|
return value !== null && value !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function querystring(params: HTTPQuery) {
|
||||||
|
return Object.keys(params)
|
||||||
|
.map((key) => {
|
||||||
|
const value = params[key];
|
||||||
|
if (value instanceof Array) {
|
||||||
|
const multiValue = value.join(`&${encodeURIComponent(key)}=`);
|
||||||
|
return `${encodeURIComponent(key)}=${multiValue}`;
|
||||||
|
}
|
||||||
|
return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
||||||
|
})
|
||||||
|
.join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
response: Response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Middleware {
|
||||||
|
pre?(context: RequestContext): Promise<FetchParams | void>;
|
||||||
|
post?(context: ResponseContext): Promise<Response | void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiResponse<T> {
|
||||||
|
raw: Response;
|
||||||
|
value(): Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseTransformer<T> {
|
||||||
|
(json: any): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class JSONApiResponse<T> {
|
||||||
|
constructor(public raw: Response, private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return this.transformer(await this.raw.json());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class VoidApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BlobApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.blob();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TextApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.text();
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"declaration": true,
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": ".",
|
||||||
|
"lib": [
|
||||||
|
"es6",
|
||||||
|
"dom"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
wwwroot/*.js
|
|
||||||
node_modules
|
|
||||||
typings
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,396 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
ModelApiResponse,
|
||||||
|
ModelApiResponseFromJSON,
|
||||||
|
ModelApiResponseToJSON,
|
||||||
|
Pet,
|
||||||
|
PetFromJSON,
|
||||||
|
PetToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface AddPetRequest {
|
||||||
|
pet: Pet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeletePetRequest {
|
||||||
|
petId: number;
|
||||||
|
apiKey?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FindPetsByStatusRequest {
|
||||||
|
status: Array<'available' | 'pending' | 'sold'>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FindPetsByTagsRequest {
|
||||||
|
tags: Array<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetPetByIdRequest {
|
||||||
|
petId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdatePetRequest {
|
||||||
|
pet: Pet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdatePetWithFormRequest {
|
||||||
|
petId: number;
|
||||||
|
name?: string;
|
||||||
|
status?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UploadFileRequest {
|
||||||
|
petId: number;
|
||||||
|
additionalMetadata?: string;
|
||||||
|
file?: Blob;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*/
|
||||||
|
async addPetRaw(requestParameters: AddPetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.pet === null || requestParameters.pet === undefined) {
|
||||||
|
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: PetToJSON(requestParameters.pet),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*/
|
||||||
|
async addPet(requestParameters: AddPetRequest): Promise<void> {
|
||||||
|
await this.addPetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*/
|
||||||
|
async deletePetRaw(requestParameters: DeletePetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) {
|
||||||
|
headerParameters['api_key'] = String(requestParameters.apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*/
|
||||||
|
async deletePet(requestParameters: DeletePetRequest): Promise<void> {
|
||||||
|
await this.deletePetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
*/
|
||||||
|
async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Promise<runtime.ApiResponse<Array<Pet>>> {
|
||||||
|
if (requestParameters.status === null || requestParameters.status === undefined) {
|
||||||
|
throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.status) {
|
||||||
|
queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/findByStatus`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
*/
|
||||||
|
async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise<Array<Pet>> {
|
||||||
|
const response = await this.findPetsByStatusRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
*/
|
||||||
|
async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Promise<runtime.ApiResponse<Array<Pet>>> {
|
||||||
|
if (requestParameters.tags === null || requestParameters.tags === undefined) {
|
||||||
|
throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.tags) {
|
||||||
|
queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/findByTags`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
*/
|
||||||
|
async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise<Array<Pet>> {
|
||||||
|
const response = await this.findPetsByTagsRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
*/
|
||||||
|
async getPetByIdRaw(requestParameters: GetPetByIdRequest): Promise<runtime.ApiResponse<Pet>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
*/
|
||||||
|
async getPetById(requestParameters: GetPetByIdRequest): Promise<Pet> {
|
||||||
|
const response = await this.getPetByIdRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*/
|
||||||
|
async updatePetRaw(requestParameters: UpdatePetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.pet === null || requestParameters.pet === undefined) {
|
||||||
|
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet`,
|
||||||
|
method: 'PUT',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: PetToJSON(requestParameters.pet),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*/
|
||||||
|
async updatePet(requestParameters: UpdatePetRequest): Promise<void> {
|
||||||
|
await this.updatePetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*/
|
||||||
|
async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
if (requestParameters.name !== undefined) {
|
||||||
|
formData.append('name', requestParameters.name as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.status !== undefined) {
|
||||||
|
formData.append('status', requestParameters.status as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*/
|
||||||
|
async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise<void> {
|
||||||
|
await this.updatePetWithFormRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*/
|
||||||
|
async uploadFileRaw(requestParameters: UploadFileRequest): Promise<runtime.ApiResponse<ModelApiResponse>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
if (requestParameters.additionalMetadata !== undefined) {
|
||||||
|
formData.append('additionalMetadata', requestParameters.additionalMetadata as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.file !== undefined) {
|
||||||
|
formData.append('file', requestParameters.file as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*/
|
||||||
|
async uploadFile(requestParameters: UploadFileRequest): Promise<ModelApiResponse> {
|
||||||
|
const response = await this.uploadFileRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
Order,
|
||||||
|
OrderFromJSON,
|
||||||
|
OrderToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface DeleteOrderRequest {
|
||||||
|
orderId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetOrderByIdRequest {
|
||||||
|
orderId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlaceOrderRequest {
|
||||||
|
order: Order;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
*/
|
||||||
|
async deleteOrderRaw(requestParameters: DeleteOrderRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.orderId === null || requestParameters.orderId === undefined) {
|
||||||
|
throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
*/
|
||||||
|
async deleteOrder(requestParameters: DeleteOrderRequest): Promise<void> {
|
||||||
|
await this.deleteOrderRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
async getInventoryRaw(): Promise<runtime.ApiResponse<{ [key: string]: number; }>> {
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/inventory`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse<any>(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
async getInventory(): Promise<{ [key: string]: number; }> {
|
||||||
|
const response = await this.getInventoryRaw();
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
*/
|
||||||
|
async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise<runtime.ApiResponse<Order>> {
|
||||||
|
if (requestParameters.orderId === null || requestParameters.orderId === undefined) {
|
||||||
|
throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
*/
|
||||||
|
async getOrderById(requestParameters: GetOrderByIdRequest): Promise<Order> {
|
||||||
|
const response = await this.getOrderByIdRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*/
|
||||||
|
async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise<runtime.ApiResponse<Order>> {
|
||||||
|
if (requestParameters.order === null || requestParameters.order === undefined) {
|
||||||
|
throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: OrderToJSON(requestParameters.order),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*/
|
||||||
|
async placeOrder(requestParameters: PlaceOrderRequest): Promise<Order> {
|
||||||
|
const response = await this.placeOrderRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,300 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
User,
|
||||||
|
UserFromJSON,
|
||||||
|
UserToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface CreateUserRequest {
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUsersWithArrayInputRequest {
|
||||||
|
user: Array<User>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUsersWithListInputRequest {
|
||||||
|
user: Array<User>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteUserRequest {
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetUserByNameRequest {
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginUserRequest {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateUserRequest {
|
||||||
|
username: string;
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
*/
|
||||||
|
async createUserRaw(requestParameters: CreateUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: UserToJSON(requestParameters.user),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
*/
|
||||||
|
async createUser(requestParameters: CreateUserRequest): Promise<void> {
|
||||||
|
await this.createUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/createWithArray`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: requestParameters.user.map(UserToJSON),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise<void> {
|
||||||
|
await this.createUsersWithArrayInputRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/createWithList`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: requestParameters.user.map(UserToJSON),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise<void> {
|
||||||
|
await this.createUsersWithListInputRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
*/
|
||||||
|
async deleteUserRaw(requestParameters: DeleteUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
*/
|
||||||
|
async deleteUser(requestParameters: DeleteUserRequest): Promise<void> {
|
||||||
|
await this.deleteUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*/
|
||||||
|
async getUserByNameRaw(requestParameters: GetUserByNameRequest): Promise<runtime.ApiResponse<User>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*/
|
||||||
|
async getUserByName(requestParameters: GetUserByNameRequest): Promise<User> {
|
||||||
|
const response = await this.getUserByNameRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*/
|
||||||
|
async loginUserRaw(requestParameters: LoginUserRequest): Promise<runtime.ApiResponse<string>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.password === null || requestParameters.password === undefined) {
|
||||||
|
throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.username !== undefined) {
|
||||||
|
queryParameters['username'] = requestParameters.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.password !== undefined) {
|
||||||
|
queryParameters['password'] = requestParameters.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/login`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.TextApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*/
|
||||||
|
async loginUser(requestParameters: LoginUserRequest): Promise<string> {
|
||||||
|
const response = await this.loginUserRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
async logoutUserRaw(): Promise<runtime.ApiResponse<void>> {
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/logout`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
async logoutUser(): Promise<void> {
|
||||||
|
await this.logoutUserRaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
*/
|
||||||
|
async updateUserRaw(requestParameters: UpdateUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'PUT',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: UserToJSON(requestParameters.user),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
*/
|
||||||
|
async updateUser(requestParameters: UpdateUserRequest): Promise<void> {
|
||||||
|
await this.updateUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
export * from './PetApi';
|
||||||
|
export * from './StoreApi';
|
||||||
|
export * from './UserApi';
|
@ -1,74 +0,0 @@
|
|||||||
// tslint:disable
|
|
||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
username?: string;
|
|
||||||
password?: string;
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
basePath?: string;
|
|
||||||
baseOptions?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Configuration {
|
|
||||||
/**
|
|
||||||
* parameter for apiKey security
|
|
||||||
* @param name security name
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
username?: string;
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
password?: string;
|
|
||||||
/**
|
|
||||||
* parameter for oauth2 security
|
|
||||||
* @param name security name
|
|
||||||
* @param scopes oauth2 scope
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
/**
|
|
||||||
* override base path
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
basePath?: string;
|
|
||||||
/**
|
|
||||||
* base options for fetch calls
|
|
||||||
*
|
|
||||||
* @type {any}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
baseOptions?: any;
|
|
||||||
|
|
||||||
constructor(param: ConfigurationParameters = {}) {
|
|
||||||
this.apiKey = param.apiKey;
|
|
||||||
this.username = param.username;
|
|
||||||
this.password = param.password;
|
|
||||||
this.accessToken = param.accessToken;
|
|
||||||
this.basePath = param.basePath;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
declare module 'portable-fetch';
|
|
||||||
declare module 'url';
|
|
@ -1,51 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
|
||||||
#
|
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
|
||||||
|
|
||||||
git_user_id=$1
|
|
||||||
git_repo_id=$2
|
|
||||||
release_note=$3
|
|
||||||
|
|
||||||
if [ "$git_user_id" = "" ]; then
|
|
||||||
git_user_id="GIT_USER_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_repo_id" = "" ]; then
|
|
||||||
git_repo_id="GIT_REPO_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$release_note" = "" ]; then
|
|
||||||
release_note="Minor update"
|
|
||||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize the local directory as a Git repository
|
|
||||||
git init
|
|
||||||
|
|
||||||
# Adds the files in the local repository and stages them for commit.
|
|
||||||
git add .
|
|
||||||
|
|
||||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
|
||||||
git commit -m "$release_note"
|
|
||||||
|
|
||||||
# Sets the new remote
|
|
||||||
git_remote=`git remote`
|
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
else
|
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
git pull origin master
|
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
|
||||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
|
@ -1,16 +1,3 @@
|
|||||||
// tslint:disable
|
export * from './runtime';
|
||||||
/**
|
export * from './apis';
|
||||||
* OpenAPI Petstore
|
export * from './models';
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export * from "./api";
|
|
||||||
export * from "./configuration";
|
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
* @export
|
||||||
|
* @interface ApiResponse
|
||||||
|
*/
|
||||||
|
export interface ApiResponse {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
code?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
type?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiResponseFromJSON(json: any): ApiResponse {
|
||||||
|
return {
|
||||||
|
'code': !exists(json, 'code') ? undefined : json['code'],
|
||||||
|
'type': !exists(json, 'type') ? undefined : json['type'],
|
||||||
|
'message': !exists(json, 'message') ? undefined : json['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiResponseToJSON(value?: ApiResponse): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'code': value.code,
|
||||||
|
'type': value.type,
|
||||||
|
'message': value.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
* @export
|
||||||
|
* @interface Category
|
||||||
|
*/
|
||||||
|
export interface Category {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Category
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Category
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CategoryFromJSON(json: any): Category {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'name': !exists(json, 'name') ? undefined : json['name'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CategoryToJSON(value?: Category): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'name': value.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
* @export
|
||||||
|
* @interface ModelApiResponse
|
||||||
|
*/
|
||||||
|
export interface ModelApiResponse {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
code?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
type?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ModelApiResponseFromJSON(json: any): ModelApiResponse {
|
||||||
|
return {
|
||||||
|
'code': !exists(json, 'code') ? undefined : json['code'],
|
||||||
|
'type': !exists(json, 'type') ? undefined : json['type'],
|
||||||
|
'message': !exists(json, 'message') ? undefined : json['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ModelApiResponseToJSON(value?: ModelApiResponse): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'code': value.code,
|
||||||
|
'type': value.type,
|
||||||
|
'message': value.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,99 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
* @export
|
||||||
|
* @interface Order
|
||||||
|
*/
|
||||||
|
export interface Order {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
petId?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
quantity?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Date}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
shipDate?: Date;
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
status?: Order.StatusEnum;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
complete?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OrderFromJSON(json: any): Order {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'petId': !exists(json, 'petId') ? undefined : json['petId'],
|
||||||
|
'quantity': !exists(json, 'quantity') ? undefined : json['quantity'],
|
||||||
|
'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']),
|
||||||
|
'status': !exists(json, 'status') ? undefined : json['status'],
|
||||||
|
'complete': !exists(json, 'complete') ? undefined : json['complete'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OrderToJSON(value?: Order): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'petId': value.petId,
|
||||||
|
'quantity': value.quantity,
|
||||||
|
'shipDate': value.shipDate === undefined ? undefined : value.shipDate.toISOString(),
|
||||||
|
'status': value.status,
|
||||||
|
'complete': value.complete,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @namespace Order
|
||||||
|
*/
|
||||||
|
export namespace Order {
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum StatusEnum {
|
||||||
|
Placed = 'placed',
|
||||||
|
Approved = 'approved',
|
||||||
|
Delivered = 'delivered'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
import {
|
||||||
|
Category,
|
||||||
|
CategoryFromJSON,
|
||||||
|
CategoryToJSON,
|
||||||
|
Tag,
|
||||||
|
TagFromJSON,
|
||||||
|
TagToJSON,
|
||||||
|
} from './';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
* @export
|
||||||
|
* @interface Pet
|
||||||
|
*/
|
||||||
|
export interface Pet {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Category}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
category?: Category;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Array<string>}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
photoUrls: Array<string>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Array<Tag>}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
tags?: Array<Tag>;
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
status?: Pet.StatusEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PetFromJSON(json: any): Pet {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']),
|
||||||
|
'name': json['name'],
|
||||||
|
'photoUrls': json['photoUrls'],
|
||||||
|
'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array<any>).map(TagFromJSON),
|
||||||
|
'status': !exists(json, 'status') ? undefined : json['status'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PetToJSON(value?: Pet): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'category': CategoryToJSON(value.category),
|
||||||
|
'name': value.name,
|
||||||
|
'photoUrls': value.photoUrls,
|
||||||
|
'tags': (value.tags as Array<any>).map(TagToJSON),
|
||||||
|
'status': value.status,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @namespace Pet
|
||||||
|
*/
|
||||||
|
export namespace Pet {
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum StatusEnum {
|
||||||
|
Available = 'available',
|
||||||
|
Pending = 'pending',
|
||||||
|
Sold = 'sold'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
* @export
|
||||||
|
* @interface Tag
|
||||||
|
*/
|
||||||
|
export interface Tag {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Tag
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Tag
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TagFromJSON(json: any): Tag {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'name': !exists(json, 'name') ? undefined : json['name'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TagToJSON(value?: Tag): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'name': value.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
* @export
|
||||||
|
* @interface User
|
||||||
|
*/
|
||||||
|
export interface User {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
username?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
firstName?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
lastName?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
email?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
password?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
phone?: string;
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
* @type {number}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
userStatus?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserFromJSON(json: any): User {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'username': !exists(json, 'username') ? undefined : json['username'],
|
||||||
|
'firstName': !exists(json, 'firstName') ? undefined : json['firstName'],
|
||||||
|
'lastName': !exists(json, 'lastName') ? undefined : json['lastName'],
|
||||||
|
'email': !exists(json, 'email') ? undefined : json['email'],
|
||||||
|
'password': !exists(json, 'password') ? undefined : json['password'],
|
||||||
|
'phone': !exists(json, 'phone') ? undefined : json['phone'],
|
||||||
|
'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserToJSON(value?: User): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'username': value.username,
|
||||||
|
'firstName': value.firstName,
|
||||||
|
'lastName': value.lastName,
|
||||||
|
'email': value.email,
|
||||||
|
'password': value.password,
|
||||||
|
'phone': value.phone,
|
||||||
|
'userStatus': value.userStatus,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
export * from './Category';
|
||||||
|
export * from './ModelApiResponse';
|
||||||
|
export * from './Order';
|
||||||
|
export * from './Pet';
|
||||||
|
export * from './Tag';
|
||||||
|
export * from './User';
|
@ -2,26 +2,14 @@
|
|||||||
"name": "@swagger/typescript-fetch-petstore",
|
"name": "@swagger/typescript-fetch-petstore",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "OpenAPI client for @swagger/typescript-fetch-petstore",
|
"description": "OpenAPI client for @swagger/typescript-fetch-petstore",
|
||||||
"author": "OpenAPI-Generator Contributors",
|
"author": "OpenAPI-Generator",
|
||||||
"keywords": [
|
|
||||||
"fetch",
|
|
||||||
"typescript",
|
|
||||||
"openapi-client",
|
|
||||||
"openapi-generator",
|
|
||||||
"@swagger/typescript-fetch-petstore"
|
|
||||||
],
|
|
||||||
"license": "Unlicense",
|
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts" : {
|
"scripts" : {
|
||||||
"build": "tsc --outDir dist/",
|
"build": "tsc --outDir dist/",
|
||||||
"prepublishOnly": "npm run build"
|
"prepare": "npm run build"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"portable-fetch": "^3.0.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^8.0.9",
|
|
||||||
"typescript": "^2.4"
|
"typescript": "^2.4"
|
||||||
},
|
},
|
||||||
"publishConfig":{
|
"publishConfig":{
|
||||||
|
@ -0,0 +1,267 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the base class for all generated API classes.
|
||||||
|
*/
|
||||||
|
export class BaseAPI {
|
||||||
|
|
||||||
|
private middleware: Middleware[];
|
||||||
|
|
||||||
|
constructor(protected configuration = new Configuration()) {
|
||||||
|
this.middleware = configuration.middleware;
|
||||||
|
}
|
||||||
|
|
||||||
|
withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
|
||||||
|
const next = this.clone<T>();
|
||||||
|
next.middleware = next.middleware.concat(...middlewares);
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
|
||||||
|
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
|
||||||
|
const middlewares = postMiddlewares.map((post) => ({ post }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async request(context: RequestOpts): Promise<Response> {
|
||||||
|
const { url, init } = this.createFetchParams(context);
|
||||||
|
const response = await this.fetchApi(url, init);
|
||||||
|
if (response.status >= 200 && response.status < 300) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
throw response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private createFetchParams(context: RequestOpts) {
|
||||||
|
let url = this.configuration.basePath + context.path;
|
||||||
|
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
||||||
|
// only add the querystring to the URL if there are query parameters.
|
||||||
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
|
// do not handle correctly sometimes.
|
||||||
|
url += '?' + querystring(context.query);
|
||||||
|
}
|
||||||
|
const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body);
|
||||||
|
const init = {
|
||||||
|
method: context.method,
|
||||||
|
headers: context.headers,
|
||||||
|
body,
|
||||||
|
};
|
||||||
|
return { url, init };
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchApi = async (url: string, init: RequestInit) => {
|
||||||
|
let fetchParams = { url, init };
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.pre) {
|
||||||
|
fetchParams = await middleware.pre({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
...fetchParams,
|
||||||
|
}) || fetchParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.post) {
|
||||||
|
response = await middleware.post({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
url,
|
||||||
|
init,
|
||||||
|
response: response.clone(),
|
||||||
|
}) || response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a shallow clone of `this` by constructing a new instance
|
||||||
|
* and then shallow cloning data members.
|
||||||
|
*/
|
||||||
|
private clone<T extends BaseAPI>(this: T): T {
|
||||||
|
const constructor = this.constructor as any;
|
||||||
|
const next = new constructor(this.configuration);
|
||||||
|
next.middleware = this.middleware.slice();
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export class RequiredError extends Error {
|
||||||
|
name: "RequiredError" = "RequiredError";
|
||||||
|
constructor(public field: string, msg?: string) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
csv: ",",
|
||||||
|
ssv: " ",
|
||||||
|
tsv: "\t",
|
||||||
|
pipes: "|",
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FetchAPI = GlobalFetch['fetch'];
|
||||||
|
|
||||||
|
export interface ConfigurationParameters {
|
||||||
|
basePath?: string; // override base path
|
||||||
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
username?: string; // parameter for basic security
|
||||||
|
password?: string; // parameter for basic security
|
||||||
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
|
accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Configuration {
|
||||||
|
constructor(private configuration: ConfigurationParameters = {}) {}
|
||||||
|
|
||||||
|
get basePath(): string {
|
||||||
|
return this.configuration.basePath || BASE_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
get fetchApi(): FetchAPI {
|
||||||
|
return this.configuration.fetchApi || window.fetch.bind(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
get middleware(): Middleware[] {
|
||||||
|
return this.configuration.middleware || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get username(): string | undefined {
|
||||||
|
return this.configuration.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
get password(): string | undefined {
|
||||||
|
return this.configuration.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
get apiKey(): ((name: string) => string) | undefined {
|
||||||
|
const apiKey = this.configuration.apiKey;
|
||||||
|
if (apiKey) {
|
||||||
|
return typeof apiKey === 'function' ? apiKey : () => apiKey;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||||
|
const accessToken = this.configuration.accessToken;
|
||||||
|
if (accessToken) {
|
||||||
|
return typeof accessToken === 'function' ? accessToken : () => accessToken;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Json = any;
|
||||||
|
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
||||||
|
export type HTTPHeaders = { [key: string]: string };
|
||||||
|
export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> };
|
||||||
|
export type HTTPBody = Json | FormData;
|
||||||
|
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
|
||||||
|
|
||||||
|
export interface FetchParams {
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestOpts {
|
||||||
|
path: string;
|
||||||
|
method: HTTPMethod;
|
||||||
|
headers: HTTPHeaders;
|
||||||
|
query?: HTTPQuery;
|
||||||
|
body?: HTTPBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exists(json: any, key: string) {
|
||||||
|
const value = json[key];
|
||||||
|
return value !== null && value !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function querystring(params: HTTPQuery) {
|
||||||
|
return Object.keys(params)
|
||||||
|
.map((key) => {
|
||||||
|
const value = params[key];
|
||||||
|
if (value instanceof Array) {
|
||||||
|
const multiValue = value.join(`&${encodeURIComponent(key)}=`);
|
||||||
|
return `${encodeURIComponent(key)}=${multiValue}`;
|
||||||
|
}
|
||||||
|
return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
||||||
|
})
|
||||||
|
.join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
response: Response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Middleware {
|
||||||
|
pre?(context: RequestContext): Promise<FetchParams | void>;
|
||||||
|
post?(context: ResponseContext): Promise<Response | void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiResponse<T> {
|
||||||
|
raw: Response;
|
||||||
|
value(): Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseTransformer<T> {
|
||||||
|
(json: any): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class JSONApiResponse<T> {
|
||||||
|
constructor(public raw: Response, private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return this.transformer(await this.raw.json());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class VoidApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BlobApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.blob();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TextApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.text();
|
||||||
|
};
|
||||||
|
}
|
@ -3,7 +3,6 @@
|
|||||||
"declaration": true,
|
"declaration": true,
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"noImplicitAny": true,
|
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"rootDir": "." },
|
"rootDir": "." },
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
wwwroot/*.js
|
|
||||||
node_modules
|
|
||||||
typings
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,396 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
ModelApiResponse,
|
||||||
|
ModelApiResponseFromJSON,
|
||||||
|
ModelApiResponseToJSON,
|
||||||
|
Pet,
|
||||||
|
PetFromJSON,
|
||||||
|
PetToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface AddPetRequest {
|
||||||
|
pet: Pet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeletePetRequest {
|
||||||
|
petId: number;
|
||||||
|
apiKey?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FindPetsByStatusRequest {
|
||||||
|
status: Array<'available' | 'pending' | 'sold'>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FindPetsByTagsRequest {
|
||||||
|
tags: Array<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetPetByIdRequest {
|
||||||
|
petId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdatePetRequest {
|
||||||
|
pet: Pet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdatePetWithFormRequest {
|
||||||
|
petId: number;
|
||||||
|
name?: string;
|
||||||
|
status?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UploadFileRequest {
|
||||||
|
petId: number;
|
||||||
|
additionalMetadata?: string;
|
||||||
|
file?: Blob;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*/
|
||||||
|
async addPetRaw(requestParameters: AddPetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.pet === null || requestParameters.pet === undefined) {
|
||||||
|
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: PetToJSON(requestParameters.pet),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*/
|
||||||
|
async addPet(requestParameters: AddPetRequest): Promise<void> {
|
||||||
|
await this.addPetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*/
|
||||||
|
async deletePetRaw(requestParameters: DeletePetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) {
|
||||||
|
headerParameters['api_key'] = String(requestParameters.apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*/
|
||||||
|
async deletePet(requestParameters: DeletePetRequest): Promise<void> {
|
||||||
|
await this.deletePetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
*/
|
||||||
|
async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Promise<runtime.ApiResponse<Array<Pet>>> {
|
||||||
|
if (requestParameters.status === null || requestParameters.status === undefined) {
|
||||||
|
throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.status) {
|
||||||
|
queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/findByStatus`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
*/
|
||||||
|
async findPetsByStatus(requestParameters: FindPetsByStatusRequest): Promise<Array<Pet>> {
|
||||||
|
const response = await this.findPetsByStatusRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
*/
|
||||||
|
async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Promise<runtime.ApiResponse<Array<Pet>>> {
|
||||||
|
if (requestParameters.tags === null || requestParameters.tags === undefined) {
|
||||||
|
throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.tags) {
|
||||||
|
queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/findByTags`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
*/
|
||||||
|
async findPetsByTags(requestParameters: FindPetsByTagsRequest): Promise<Array<Pet>> {
|
||||||
|
const response = await this.findPetsByTagsRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
*/
|
||||||
|
async getPetByIdRaw(requestParameters: GetPetByIdRequest): Promise<runtime.ApiResponse<Pet>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
*/
|
||||||
|
async getPetById(requestParameters: GetPetByIdRequest): Promise<Pet> {
|
||||||
|
const response = await this.getPetByIdRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*/
|
||||||
|
async updatePetRaw(requestParameters: UpdatePetRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.pet === null || requestParameters.pet === undefined) {
|
||||||
|
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet`,
|
||||||
|
method: 'PUT',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: PetToJSON(requestParameters.pet),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*/
|
||||||
|
async updatePet(requestParameters: UpdatePetRequest): Promise<void> {
|
||||||
|
await this.updatePetRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*/
|
||||||
|
async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
if (requestParameters.name !== undefined) {
|
||||||
|
formData.append('name', requestParameters.name as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.status !== undefined) {
|
||||||
|
formData.append('status', requestParameters.status as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*/
|
||||||
|
async updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Promise<void> {
|
||||||
|
await this.updatePetWithFormRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*/
|
||||||
|
async uploadFileRaw(requestParameters: UploadFileRequest): Promise<runtime.ApiResponse<ModelApiResponse>> {
|
||||||
|
if (requestParameters.petId === null || requestParameters.petId === undefined) {
|
||||||
|
throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
if (typeof this.configuration.accessToken === 'function') {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
|
} else {
|
||||||
|
headerParameters["Authorization"] = this.configuration.accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
if (requestParameters.additionalMetadata !== undefined) {
|
||||||
|
formData.append('additionalMetadata', requestParameters.additionalMetadata as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.file !== undefined) {
|
||||||
|
formData.append('file', requestParameters.file as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*/
|
||||||
|
async uploadFile(requestParameters: UploadFileRequest): Promise<ModelApiResponse> {
|
||||||
|
const response = await this.uploadFileRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
Order,
|
||||||
|
OrderFromJSON,
|
||||||
|
OrderToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface DeleteOrderRequest {
|
||||||
|
orderId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetOrderByIdRequest {
|
||||||
|
orderId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlaceOrderRequest {
|
||||||
|
order: Order;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
*/
|
||||||
|
async deleteOrderRaw(requestParameters: DeleteOrderRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.orderId === null || requestParameters.orderId === undefined) {
|
||||||
|
throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
*/
|
||||||
|
async deleteOrder(requestParameters: DeleteOrderRequest): Promise<void> {
|
||||||
|
await this.deleteOrderRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
async getInventoryRaw(): Promise<runtime.ApiResponse<{ [key: string]: number; }>> {
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.apiKey) {
|
||||||
|
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/inventory`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse<any>(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
async getInventory(): Promise<{ [key: string]: number; }> {
|
||||||
|
const response = await this.getInventoryRaw();
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
*/
|
||||||
|
async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise<runtime.ApiResponse<Order>> {
|
||||||
|
if (requestParameters.orderId === null || requestParameters.orderId === undefined) {
|
||||||
|
throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
*/
|
||||||
|
async getOrderById(requestParameters: GetOrderByIdRequest): Promise<Order> {
|
||||||
|
const response = await this.getOrderByIdRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*/
|
||||||
|
async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise<runtime.ApiResponse<Order>> {
|
||||||
|
if (requestParameters.order === null || requestParameters.order === undefined) {
|
||||||
|
throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/store/order`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: OrderToJSON(requestParameters.order),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*/
|
||||||
|
async placeOrder(requestParameters: PlaceOrderRequest): Promise<Order> {
|
||||||
|
const response = await this.placeOrderRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,300 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as runtime from '../runtime';
|
||||||
|
import {
|
||||||
|
User,
|
||||||
|
UserFromJSON,
|
||||||
|
UserToJSON,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
export interface CreateUserRequest {
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUsersWithArrayInputRequest {
|
||||||
|
user: Array<User>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUsersWithListInputRequest {
|
||||||
|
user: Array<User>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteUserRequest {
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetUserByNameRequest {
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginUserRequest {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateUserRequest {
|
||||||
|
username: string;
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
*/
|
||||||
|
async createUserRaw(requestParameters: CreateUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: UserToJSON(requestParameters.user),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
*/
|
||||||
|
async createUser(requestParameters: CreateUserRequest): Promise<void> {
|
||||||
|
await this.createUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/createWithArray`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: requestParameters.user.map(UserToJSON),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest): Promise<void> {
|
||||||
|
await this.createUsersWithArrayInputRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/createWithList`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: requestParameters.user.map(UserToJSON),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*/
|
||||||
|
async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest): Promise<void> {
|
||||||
|
await this.createUsersWithListInputRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
*/
|
||||||
|
async deleteUserRaw(requestParameters: DeleteUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
*/
|
||||||
|
async deleteUser(requestParameters: DeleteUserRequest): Promise<void> {
|
||||||
|
await this.deleteUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*/
|
||||||
|
async getUserByNameRaw(requestParameters: GetUserByNameRequest): Promise<runtime.ApiResponse<User>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*/
|
||||||
|
async getUserByName(requestParameters: GetUserByNameRequest): Promise<User> {
|
||||||
|
const response = await this.getUserByNameRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*/
|
||||||
|
async loginUserRaw(requestParameters: LoginUserRequest): Promise<runtime.ApiResponse<string>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.password === null || requestParameters.password === undefined) {
|
||||||
|
throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: runtime.HTTPQuery = {};
|
||||||
|
|
||||||
|
if (requestParameters.username !== undefined) {
|
||||||
|
queryParameters['username'] = requestParameters.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.password !== undefined) {
|
||||||
|
queryParameters['password'] = requestParameters.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/login`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.TextApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*/
|
||||||
|
async loginUser(requestParameters: LoginUserRequest): Promise<string> {
|
||||||
|
const response = await this.loginUserRaw(requestParameters);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
async logoutUserRaw(): Promise<runtime.ApiResponse<void>> {
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/logout`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: headerParameters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
async logoutUser(): Promise<void> {
|
||||||
|
await this.logoutUserRaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
*/
|
||||||
|
async updateUserRaw(requestParameters: UpdateUserRequest): Promise<runtime.ApiResponse<void>> {
|
||||||
|
if (requestParameters.username === null || requestParameters.username === undefined) {
|
||||||
|
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestParameters.user === null || requestParameters.user === undefined) {
|
||||||
|
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
headerParameters['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const response = await this.request({
|
||||||
|
path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
|
||||||
|
method: 'PUT',
|
||||||
|
headers: headerParameters,
|
||||||
|
body: UserToJSON(requestParameters.user),
|
||||||
|
});
|
||||||
|
|
||||||
|
return new runtime.VoidApiResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
*/
|
||||||
|
async updateUser(requestParameters: UpdateUserRequest): Promise<void> {
|
||||||
|
await this.updateUserRaw(requestParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
export * from './PetApi';
|
||||||
|
export * from './StoreApi';
|
||||||
|
export * from './UserApi';
|
@ -1,74 +0,0 @@
|
|||||||
// tslint:disable
|
|
||||||
/**
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
username?: string;
|
|
||||||
password?: string;
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
basePath?: string;
|
|
||||||
baseOptions?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Configuration {
|
|
||||||
/**
|
|
||||||
* parameter for apiKey security
|
|
||||||
* @param name security name
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
apiKey?: string | ((name: string) => string);
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
username?: string;
|
|
||||||
/**
|
|
||||||
* parameter for basic security
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
password?: string;
|
|
||||||
/**
|
|
||||||
* parameter for oauth2 security
|
|
||||||
* @param name security name
|
|
||||||
* @param scopes oauth2 scope
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
|
||||||
/**
|
|
||||||
* override base path
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
basePath?: string;
|
|
||||||
/**
|
|
||||||
* base options for fetch calls
|
|
||||||
*
|
|
||||||
* @type {any}
|
|
||||||
* @memberof Configuration
|
|
||||||
*/
|
|
||||||
baseOptions?: any;
|
|
||||||
|
|
||||||
constructor(param: ConfigurationParameters = {}) {
|
|
||||||
this.apiKey = param.apiKey;
|
|
||||||
this.username = param.username;
|
|
||||||
this.password = param.password;
|
|
||||||
this.accessToken = param.accessToken;
|
|
||||||
this.basePath = param.basePath;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
declare module 'portable-fetch';
|
|
||||||
declare module 'url';
|
|
@ -1,51 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
|
||||||
#
|
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
|
||||||
|
|
||||||
git_user_id=$1
|
|
||||||
git_repo_id=$2
|
|
||||||
release_note=$3
|
|
||||||
|
|
||||||
if [ "$git_user_id" = "" ]; then
|
|
||||||
git_user_id="GIT_USER_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_repo_id" = "" ]; then
|
|
||||||
git_repo_id="GIT_REPO_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$release_note" = "" ]; then
|
|
||||||
release_note="Minor update"
|
|
||||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize the local directory as a Git repository
|
|
||||||
git init
|
|
||||||
|
|
||||||
# Adds the files in the local repository and stages them for commit.
|
|
||||||
git add .
|
|
||||||
|
|
||||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
|
||||||
git commit -m "$release_note"
|
|
||||||
|
|
||||||
# Sets the new remote
|
|
||||||
git_remote=`git remote`
|
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
else
|
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
git pull origin master
|
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
|
||||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
|
@ -1,16 +1,3 @@
|
|||||||
// tslint:disable
|
export * from './runtime';
|
||||||
/**
|
export * from './apis';
|
||||||
* OpenAPI Petstore
|
export * from './models';
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export * from "./api";
|
|
||||||
export * from "./configuration";
|
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
* @export
|
||||||
|
* @interface ApiResponse
|
||||||
|
*/
|
||||||
|
export interface ApiResponse {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
code?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
type?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ApiResponse
|
||||||
|
*/
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiResponseFromJSON(json: any): ApiResponse {
|
||||||
|
return {
|
||||||
|
'code': !exists(json, 'code') ? undefined : json['code'],
|
||||||
|
'type': !exists(json, 'type') ? undefined : json['type'],
|
||||||
|
'message': !exists(json, 'message') ? undefined : json['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ApiResponseToJSON(value?: ApiResponse): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'code': value.code,
|
||||||
|
'type': value.type,
|
||||||
|
'message': value.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
* @export
|
||||||
|
* @interface Category
|
||||||
|
*/
|
||||||
|
export interface Category {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Category
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Category
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CategoryFromJSON(json: any): Category {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'name': !exists(json, 'name') ? undefined : json['name'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CategoryToJSON(value?: Category): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'name': value.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
* @export
|
||||||
|
* @interface ModelApiResponse
|
||||||
|
*/
|
||||||
|
export interface ModelApiResponse {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
code?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
type?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ModelApiResponse
|
||||||
|
*/
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ModelApiResponseFromJSON(json: any): ModelApiResponse {
|
||||||
|
return {
|
||||||
|
'code': !exists(json, 'code') ? undefined : json['code'],
|
||||||
|
'type': !exists(json, 'type') ? undefined : json['type'],
|
||||||
|
'message': !exists(json, 'message') ? undefined : json['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ModelApiResponseToJSON(value?: ModelApiResponse): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'code': value.code,
|
||||||
|
'type': value.type,
|
||||||
|
'message': value.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,99 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
* @export
|
||||||
|
* @interface Order
|
||||||
|
*/
|
||||||
|
export interface Order {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
petId?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
quantity?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Date}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
shipDate?: Date;
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
status?: Order.StatusEnum;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof Order
|
||||||
|
*/
|
||||||
|
complete?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OrderFromJSON(json: any): Order {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'petId': !exists(json, 'petId') ? undefined : json['petId'],
|
||||||
|
'quantity': !exists(json, 'quantity') ? undefined : json['quantity'],
|
||||||
|
'shipDate': !exists(json, 'shipDate') ? undefined : new Date(json['shipDate']),
|
||||||
|
'status': !exists(json, 'status') ? undefined : json['status'],
|
||||||
|
'complete': !exists(json, 'complete') ? undefined : json['complete'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OrderToJSON(value?: Order): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'petId': value.petId,
|
||||||
|
'quantity': value.quantity,
|
||||||
|
'shipDate': value.shipDate === undefined ? undefined : value.shipDate.toISOString(),
|
||||||
|
'status': value.status,
|
||||||
|
'complete': value.complete,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @namespace Order
|
||||||
|
*/
|
||||||
|
export namespace Order {
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum StatusEnum {
|
||||||
|
Placed = 'placed',
|
||||||
|
Approved = 'approved',
|
||||||
|
Delivered = 'delivered'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
import {
|
||||||
|
Category,
|
||||||
|
CategoryFromJSON,
|
||||||
|
CategoryToJSON,
|
||||||
|
Tag,
|
||||||
|
TagFromJSON,
|
||||||
|
TagToJSON,
|
||||||
|
} from './';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
* @export
|
||||||
|
* @interface Pet
|
||||||
|
*/
|
||||||
|
export interface Pet {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Category}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
category?: Category;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Array<string>}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
photoUrls: Array<string>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Array<Tag>}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
tags?: Array<Tag>;
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Pet
|
||||||
|
*/
|
||||||
|
status?: Pet.StatusEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PetFromJSON(json: any): Pet {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']),
|
||||||
|
'name': json['name'],
|
||||||
|
'photoUrls': json['photoUrls'],
|
||||||
|
'tags': !exists(json, 'tags') ? undefined : (json['tags'] as Array<any>).map(TagFromJSON),
|
||||||
|
'status': !exists(json, 'status') ? undefined : json['status'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PetToJSON(value?: Pet): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'category': CategoryToJSON(value.category),
|
||||||
|
'name': value.name,
|
||||||
|
'photoUrls': value.photoUrls,
|
||||||
|
'tags': (value.tags as Array<any>).map(TagToJSON),
|
||||||
|
'status': value.status,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @namespace Pet
|
||||||
|
*/
|
||||||
|
export namespace Pet {
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum StatusEnum {
|
||||||
|
Available = 'available',
|
||||||
|
Pending = 'pending',
|
||||||
|
Sold = 'sold'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
* @export
|
||||||
|
* @interface Tag
|
||||||
|
*/
|
||||||
|
export interface Tag {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Tag
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Tag
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TagFromJSON(json: any): Tag {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'name': !exists(json, 'name') ? undefined : json['name'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TagToJSON(value?: Tag): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'name': value.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { exists } from '../runtime';
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
* @export
|
||||||
|
* @interface User
|
||||||
|
*/
|
||||||
|
export interface User {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
username?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
firstName?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
lastName?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
email?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
password?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
phone?: string;
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
* @type {number}
|
||||||
|
* @memberof User
|
||||||
|
*/
|
||||||
|
userStatus?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserFromJSON(json: any): User {
|
||||||
|
return {
|
||||||
|
'id': !exists(json, 'id') ? undefined : json['id'],
|
||||||
|
'username': !exists(json, 'username') ? undefined : json['username'],
|
||||||
|
'firstName': !exists(json, 'firstName') ? undefined : json['firstName'],
|
||||||
|
'lastName': !exists(json, 'lastName') ? undefined : json['lastName'],
|
||||||
|
'email': !exists(json, 'email') ? undefined : json['email'],
|
||||||
|
'password': !exists(json, 'password') ? undefined : json['password'],
|
||||||
|
'phone': !exists(json, 'phone') ? undefined : json['phone'],
|
||||||
|
'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserToJSON(value?: User): any {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'id': value.id,
|
||||||
|
'username': value.username,
|
||||||
|
'firstName': value.firstName,
|
||||||
|
'lastName': value.lastName,
|
||||||
|
'email': value.email,
|
||||||
|
'password': value.password,
|
||||||
|
'phone': value.phone,
|
||||||
|
'userStatus': value.userStatus,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
export * from './Category';
|
||||||
|
export * from './ModelApiResponse';
|
||||||
|
export * from './Order';
|
||||||
|
export * from './Pet';
|
||||||
|
export * from './Tag';
|
||||||
|
export * from './User';
|
@ -0,0 +1,267 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the base class for all generated API classes.
|
||||||
|
*/
|
||||||
|
export class BaseAPI {
|
||||||
|
|
||||||
|
private middleware: Middleware[];
|
||||||
|
|
||||||
|
constructor(protected configuration = new Configuration()) {
|
||||||
|
this.middleware = configuration.middleware;
|
||||||
|
}
|
||||||
|
|
||||||
|
withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
|
||||||
|
const next = this.clone<T>();
|
||||||
|
next.middleware = next.middleware.concat(...middlewares);
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
|
||||||
|
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
|
||||||
|
const middlewares = postMiddlewares.map((post) => ({ post }));
|
||||||
|
return this.withMiddleware<T>(...middlewares);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async request(context: RequestOpts): Promise<Response> {
|
||||||
|
const { url, init } = this.createFetchParams(context);
|
||||||
|
const response = await this.fetchApi(url, init);
|
||||||
|
if (response.status >= 200 && response.status < 300) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
throw response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private createFetchParams(context: RequestOpts) {
|
||||||
|
let url = this.configuration.basePath + context.path;
|
||||||
|
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
||||||
|
// only add the querystring to the URL if there are query parameters.
|
||||||
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
|
// do not handle correctly sometimes.
|
||||||
|
url += '?' + querystring(context.query);
|
||||||
|
}
|
||||||
|
const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body);
|
||||||
|
const init = {
|
||||||
|
method: context.method,
|
||||||
|
headers: context.headers,
|
||||||
|
body,
|
||||||
|
};
|
||||||
|
return { url, init };
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchApi = async (url: string, init: RequestInit) => {
|
||||||
|
let fetchParams = { url, init };
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.pre) {
|
||||||
|
fetchParams = await middleware.pre({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
...fetchParams,
|
||||||
|
}) || fetchParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
|
||||||
|
for (const middleware of this.middleware) {
|
||||||
|
if (middleware.post) {
|
||||||
|
response = await middleware.post({
|
||||||
|
fetch: this.fetchApi,
|
||||||
|
url,
|
||||||
|
init,
|
||||||
|
response: response.clone(),
|
||||||
|
}) || response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a shallow clone of `this` by constructing a new instance
|
||||||
|
* and then shallow cloning data members.
|
||||||
|
*/
|
||||||
|
private clone<T extends BaseAPI>(this: T): T {
|
||||||
|
const constructor = this.constructor as any;
|
||||||
|
const next = new constructor(this.configuration);
|
||||||
|
next.middleware = this.middleware.slice();
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export class RequiredError extends Error {
|
||||||
|
name: "RequiredError" = "RequiredError";
|
||||||
|
constructor(public field: string, msg?: string) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
csv: ",",
|
||||||
|
ssv: " ",
|
||||||
|
tsv: "\t",
|
||||||
|
pipes: "|",
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FetchAPI = GlobalFetch['fetch'];
|
||||||
|
|
||||||
|
export interface ConfigurationParameters {
|
||||||
|
basePath?: string; // override base path
|
||||||
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
username?: string; // parameter for basic security
|
||||||
|
password?: string; // parameter for basic security
|
||||||
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
|
accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Configuration {
|
||||||
|
constructor(private configuration: ConfigurationParameters = {}) {}
|
||||||
|
|
||||||
|
get basePath(): string {
|
||||||
|
return this.configuration.basePath || BASE_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
get fetchApi(): FetchAPI {
|
||||||
|
return this.configuration.fetchApi || window.fetch.bind(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
get middleware(): Middleware[] {
|
||||||
|
return this.configuration.middleware || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get username(): string | undefined {
|
||||||
|
return this.configuration.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
get password(): string | undefined {
|
||||||
|
return this.configuration.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
get apiKey(): ((name: string) => string) | undefined {
|
||||||
|
const apiKey = this.configuration.apiKey;
|
||||||
|
if (apiKey) {
|
||||||
|
return typeof apiKey === 'function' ? apiKey : () => apiKey;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||||
|
const accessToken = this.configuration.accessToken;
|
||||||
|
if (accessToken) {
|
||||||
|
return typeof accessToken === 'function' ? accessToken : () => accessToken;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Json = any;
|
||||||
|
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
||||||
|
export type HTTPHeaders = { [key: string]: string };
|
||||||
|
export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> };
|
||||||
|
export type HTTPBody = Json | FormData;
|
||||||
|
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
|
||||||
|
|
||||||
|
export interface FetchParams {
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestOpts {
|
||||||
|
path: string;
|
||||||
|
method: HTTPMethod;
|
||||||
|
headers: HTTPHeaders;
|
||||||
|
query?: HTTPQuery;
|
||||||
|
body?: HTTPBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exists(json: any, key: string) {
|
||||||
|
const value = json[key];
|
||||||
|
return value !== null && value !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function querystring(params: HTTPQuery) {
|
||||||
|
return Object.keys(params)
|
||||||
|
.map((key) => {
|
||||||
|
const value = params[key];
|
||||||
|
if (value instanceof Array) {
|
||||||
|
const multiValue = value.join(`&${encodeURIComponent(key)}=`);
|
||||||
|
return `${encodeURIComponent(key)}=${multiValue}`;
|
||||||
|
}
|
||||||
|
return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
||||||
|
})
|
||||||
|
.join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseContext {
|
||||||
|
fetch: FetchAPI;
|
||||||
|
url: string;
|
||||||
|
init: RequestInit;
|
||||||
|
response: Response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Middleware {
|
||||||
|
pre?(context: RequestContext): Promise<FetchParams | void>;
|
||||||
|
post?(context: ResponseContext): Promise<Response | void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiResponse<T> {
|
||||||
|
raw: Response;
|
||||||
|
value(): Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseTransformer<T> {
|
||||||
|
(json: any): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class JSONApiResponse<T> {
|
||||||
|
constructor(public raw: Response, private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return this.transformer(await this.raw.json());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class VoidApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BlobApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.blob();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TextApiResponse {
|
||||||
|
constructor(public raw: Response) {}
|
||||||
|
|
||||||
|
async value() {
|
||||||
|
return await this.raw.text();
|
||||||
|
};
|
||||||
|
}
|
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