Skip to content

Commit 334415d

Browse files
Place1wing328
authored andcommitted
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.
1 parent 736e834 commit 334415d

File tree

133 files changed

+11386
-8643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+11386
-8643
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>TypeScriptAngularBuildPestoreClientTests</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>TS Fetch Default Petstore Client</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
</plugins>
25+
</build>
26+
</project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>TypeScriptAngularBuildES6PestoreClientTests</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>TS Fetch ES6 Petstore Client</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.codehaus.mojo</groupId>
26+
<artifactId>exec-maven-plugin</artifactId>
27+
<version>1.2.1</version>
28+
<executions>
29+
<execution>
30+
<id>npm-install</id>
31+
<phase>integration-test</phase>
32+
<goals>
33+
<goal>exec</goal>
34+
</goals>
35+
<configuration>
36+
<executable>npm</executable>
37+
<arguments>
38+
<argument>install</argument>
39+
</arguments>
40+
</configuration>
41+
</execution>
42+
<execution>
43+
<id>npm-test</id>
44+
<phase>integration-test</phase>
45+
<goals>
46+
<goal>exec</goal>
47+
</goals>
48+
<configuration>
49+
<executable>npm</executable>
50+
<arguments>
51+
<argument>test</argument>
52+
</arguments>
53+
</configuration>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
</project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>TypeScriptAngularBuildWithNPMVersionPestoreClientTests</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>TS Fetch Petstore Client (with npm)</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.codehaus.mojo</groupId>
26+
<artifactId>exec-maven-plugin</artifactId>
27+
<version>1.2.1</version>
28+
<executions>
29+
<execution>
30+
<id>npm-install</id>
31+
<phase>integration-test</phase>
32+
<goals>
33+
<goal>exec</goal>
34+
</goals>
35+
<configuration>
36+
<executable>npm</executable>
37+
<arguments>
38+
<argument>install</argument>
39+
</arguments>
40+
</configuration>
41+
</execution>
42+
<execution>
43+
<id>npm-build</id>
44+
<phase>integration-test</phase>
45+
<goals>
46+
<goal>exec</goal>
47+
</goals>
48+
<configuration>
49+
<executable>npm</executable>
50+
<arguments>
51+
<argument>run</argument>
52+
<argument>build</argument>
53+
</arguments>
54+
</configuration>
55+
</execution>
56+
<execution>
57+
<id>npm-test</id>
58+
<phase>integration-test</phase>
59+
<goals>
60+
<goal>exec</goal>
61+
</goals>
62+
<configuration>
63+
<executable>npm</executable>
64+
<arguments>
65+
<argument>test</argument>
66+
</arguments>
67+
</configuration>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
</project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>TypeScriptFetchPestoreClientTests</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>TS Fetch Petstore Test Client</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.codehaus.mojo</groupId>
26+
<artifactId>exec-maven-plugin</artifactId>
27+
<version>1.2.1</version>
28+
<executions>
29+
<execution>
30+
<id>npm-install</id>
31+
<phase>pre-integration-test</phase>
32+
<goals>
33+
<goal>exec</goal>
34+
</goals>
35+
<configuration>
36+
<executable>npm</executable>
37+
<arguments>
38+
<argument>install</argument>
39+
</arguments>
40+
</configuration>
41+
</execution>
42+
<execution>
43+
<id>npm-test</id>
44+
<phase>integration-test</phase>
45+
<goals>
46+
<goal>exec</goal>
47+
</goals>
48+
<configuration>
49+
<executable>npm</executable>
50+
<arguments>
51+
<argument>test</argument>
52+
</arguments>
53+
</configuration>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c2fcc2ae9693a8e8d02b25e286844aad88188fcb
5.75 KB
Binary file not shown.

bin/typescript-fetch-petstore-target-es6.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
3030
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 $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
cp CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml samples/client/petstore/typescript-fetch/builds/es6-target/pom.xml
34+
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml

bin/typescript-fetch-petstore-with-npm-version.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
3030
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 $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
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
34+
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml

bin/typescript-fetch-petstore.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
3030
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-fetch -o samples/client/petstore/typescript-fetch/builds/default $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags
33+
cp CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml samples/client/petstore/typescript-fetch/builds/default/pom.xml
34+
cp CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml samples/client/petstore/typescript-fetch/tests/default/pom.xml
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.openapitools.generator.gradle.plugin
18+
19+
import org.gradle.api.Plugin
20+
import org.gradle.api.Project
21+
import org.gradle.kotlin.dsl.invoke
22+
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension
23+
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension
24+
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension
25+
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
26+
import org.openapitools.generator.gradle.plugin.tasks.GeneratorsTask
27+
import org.openapitools.generator.gradle.plugin.tasks.MetaTask
28+
import org.openapitools.generator.gradle.plugin.tasks.ValidateTask
29+
30+
/**
31+
* A plugin providing common Open API Generator use cases.
32+
*
33+
* @author Jim Schubert
34+
*/
35+
@Suppress("unused")
36+
class OpenApiGeneratorPlugin : Plugin<Project> {
37+
override fun apply(project: Project) {
38+
project.run {
39+
val meta = extensions.create(
40+
"openApiMeta",
41+
OpenApiGeneratorMetaExtension::class.java,
42+
project
43+
)
44+
45+
val validate = extensions.create(
46+
"openApiValidate",
47+
OpenApiGeneratorValidateExtension::class.java,
48+
project
49+
)
50+
51+
val generate = extensions.create(
52+
"openApiGenerate",
53+
OpenApiGeneratorGenerateExtension::class.java,
54+
project
55+
)
56+
57+
generate.outputDir.set("$buildDir/generate-resources/main")
58+
59+
tasks {
60+
"openApiGenerators"(GeneratorsTask::class) {
61+
group = pluginGroup
62+
description = "Lists generators available via Open API Generators."
63+
}
64+
"openApiMeta"(MetaTask::class) {
65+
group = pluginGroup
66+
description = "Generates a new generator to be consumed via Open API Generator."
67+
68+
generatorName.set(meta.generatorName)
69+
packageName.set(meta.packageName)
70+
outputFolder.set(meta.outputFolder)
71+
}
72+
"openApiValidate"(ValidateTask::class) {
73+
group = pluginGroup
74+
description = "Validates an Open API 2.0 or 3.x specification document."
75+
76+
inputSpec.set(validate.inputSpec)
77+
}
78+
"openApiGenerate"(GenerateTask::class) {
79+
group = pluginGroup
80+
description = "Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents."
81+
82+
verbose.set(generate.verbose)
83+
validateSpec.set(generate.validateSpec)
84+
generatorName.set(generate.generatorName)
85+
outputDir.set(generate.outputDir)
86+
inputSpec.set(generate.inputSpec)
87+
templateDir.set(generate.templateDir)
88+
auth.set(generate.auth)
89+
systemProperties.set(generate.systemProperties)
90+
configFile.set(generate.configFile)
91+
skipOverwrite.set(generate.skipOverwrite)
92+
apiPackage.set(generate.apiPackage)
93+
modelPackage.set(generate.modelPackage)
94+
modelNamePrefix.set(generate.modelNamePrefix)
95+
modelNameSuffix.set(generate.modelNameSuffix)
96+
instantiationTypes.set(generate.instantiationTypes)
97+
typeMappings.set(generate.typeMappings)
98+
additionalProperties.set(generate.additionalProperties)
99+
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
100+
importMappings.set(generate.importMappings)
101+
invokerPackage.set(generate.invokerPackage)
102+
groupId.set(generate.groupId)
103+
id.set(generate.id)
104+
version.set(generate.version)
105+
library.set(generate.library)
106+
gitUserId.set(generate.gitUserId)
107+
gitRepoId.set(generate.gitRepoId)
108+
releaseNote.set(generate.releaseNote)
109+
httpUserAgent.set(generate.httpUserAgent)
110+
reservedWordsMappings.set(generate.reservedWordsMappings)
111+
ignoreFileOverride.set(generate.ignoreFileOverride)
112+
removeOperationIdPrefix.set(generate.removeOperationIdPrefix)
113+
apiFilesConstrainedTo.set(generate.apiFilesConstrainedTo)
114+
modelFilesConstrainedTo.set(generate.modelFilesConstrainedTo)
115+
supportingFilesConstrainedTo.set(generate.supportingFilesConstrainedTo)
116+
generateModelTests.set(generate.generateModelTests)
117+
generateModelDocumentation.set(generate.generateModelDocumentation)
118+
generateApiTests.set(generate.generateApiTests)
119+
generateApiDocumentation.set(generate.generateApiDocumentation)
120+
withXml.set(generate.withXml)
121+
configOptions.set(generate.configOptions)
122+
}
123+
}
124+
}
125+
}
126+
127+
companion object {
128+
const val pluginGroup = "OpenAPI Tools"
129+
}
130+
}
131+

0 commit comments

Comments
 (0)