Skip to content

Commit ce49fe5

Browse files
erithmeticwing328
andauthored
Generator for JavaScript/Apollo Client (#5645)
Co-authored-by: William Cheng <wing328hk@gmail.com>
1 parent 527d5e4 commit ce49fe5

27 files changed

Lines changed: 2678 additions & 1 deletion

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
6464

6565
| | Languages/Frameworks |
6666
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67-
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client), **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs) |
67+
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client), **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs) |
6868
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
6969
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc** |
7070
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
@@ -803,6 +803,7 @@ Here is a list of template creators:
803803
* Java (Rest-assured): @viclovsky
804804
* Java (Java 11 Native HTTP client): @bbdouglas
805805
* Javascript/NodeJS: @jfiala
806+
* Javascript (Apollo DataSource): @erithmetic
806807
* Javascript (Closure-annotated Angular) @achew22
807808
* Javascript (Flow types) @jaypea
808809
* JMeter: @davidkiss

bin/javascript-apollo-petstore.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
echo "# START SCRIPT: $SCRIPT"
5+
6+
while [ -h "$SCRIPT" ] ; do
7+
ls=`ls -ld "$SCRIPT"`
8+
link=`expr "$ls" : '.*-> \(.*\)$'`
9+
if expr "$link" : '/.*' > /dev/null; then
10+
SCRIPT="$link"
11+
else
12+
SCRIPT=`dirname "$SCRIPT"`/"$link"
13+
fi
14+
done
15+
16+
if [ ! -d "${APP_DIR}" ]; then
17+
APP_DIR=`dirname "$SCRIPT"`/..
18+
APP_DIR=`cd "${APP_DIR}"; pwd`
19+
fi
20+
21+
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
22+
23+
if [ ! -f "$executable" ]
24+
then
25+
mvn -B clean package
26+
fi
27+
28+
# if you've executed sbt assembly previously it will use that instead.
29+
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30+
ags="generate -t modules/openapi-generator/src/main/resources/Javascript-Apollo -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g javascript-apollo -o samples/client/petstore/javascript-apollo --additional-properties appName=PetstoreClient $@"
31+
32+
java $JAVA_OPTS -jar $executable $ags
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
---
2+
title: Config Options for javascript-apollo
3+
sidebar_label: javascript-apollo
4+
---
5+
6+
| Option | Description | Values | Default |
7+
| ------ | ----------- | ------ | ------- |
8+
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
9+
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
10+
|enumNameSuffix|Suffix that will be appended to all enum names. A special 'v4-compat' value enables the backward-compatible behavior (as pre v4.2.3)| |v4-compat|
11+
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
12+
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
13+
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
14+
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
15+
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
16+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
17+
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
18+
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
19+
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
20+
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
21+
22+
## IMPORT MAPPING
23+
24+
| Type/Alias | Imports |
25+
| ---------- | ------- |
26+
27+
28+
## INSTANTIATION TYPES
29+
30+
| Type/Alias | Instantiated By |
31+
| ---------- | --------------- |
32+
|array|Array|
33+
|list|Array|
34+
|map|Object|
35+
36+
37+
## LANGUAGE PRIMITIVES
38+
39+
<ul class="column-ul">
40+
<li>Array</li>
41+
<li>Blob</li>
42+
<li>Date</li>
43+
<li>File</li>
44+
<li>Object</li>
45+
<li>boolean</li>
46+
<li>number</li>
47+
<li>string</li>
48+
</ul>
49+
50+
## RESERVED WORDS
51+
52+
<ul class="column-ul">
53+
<li>abstract</li>
54+
<li>arguments</li>
55+
<li>array</li>
56+
<li>boolean</li>
57+
<li>break</li>
58+
<li>byte</li>
59+
<li>case</li>
60+
<li>catch</li>
61+
<li>char</li>
62+
<li>class</li>
63+
<li>const</li>
64+
<li>continue</li>
65+
<li>date</li>
66+
<li>debugger</li>
67+
<li>default</li>
68+
<li>delete</li>
69+
<li>do</li>
70+
<li>double</li>
71+
<li>else</li>
72+
<li>enum</li>
73+
<li>eval</li>
74+
<li>export</li>
75+
<li>extends</li>
76+
<li>false</li>
77+
<li>final</li>
78+
<li>finally</li>
79+
<li>float</li>
80+
<li>for</li>
81+
<li>formparams</li>
82+
<li>function</li>
83+
<li>goto</li>
84+
<li>hasownproperty</li>
85+
<li>headerparams</li>
86+
<li>if</li>
87+
<li>implements</li>
88+
<li>import</li>
89+
<li>in</li>
90+
<li>infinity</li>
91+
<li>instanceof</li>
92+
<li>int</li>
93+
<li>interface</li>
94+
<li>isfinite</li>
95+
<li>isnan</li>
96+
<li>isprototypeof</li>
97+
<li>let</li>
98+
<li>long</li>
99+
<li>math</li>
100+
<li>nan</li>
101+
<li>native</li>
102+
<li>new</li>
103+
<li>null</li>
104+
<li>number</li>
105+
<li>object</li>
106+
<li>package</li>
107+
<li>private</li>
108+
<li>protected</li>
109+
<li>prototype</li>
110+
<li>public</li>
111+
<li>queryparameters</li>
112+
<li>requestoptions</li>
113+
<li>return</li>
114+
<li>short</li>
115+
<li>static</li>
116+
<li>string</li>
117+
<li>super</li>
118+
<li>switch</li>
119+
<li>synchronized</li>
120+
<li>this</li>
121+
<li>throw</li>
122+
<li>throws</li>
123+
<li>tostring</li>
124+
<li>transient</li>
125+
<li>true</li>
126+
<li>try</li>
127+
<li>typeof</li>
128+
<li>undefined</li>
129+
<li>useformdata</li>
130+
<li>valueof</li>
131+
<li>var</li>
132+
<li>varlocaldeferred</li>
133+
<li>varlocalpath</li>
134+
<li>void</li>
135+
<li>volatile</li>
136+
<li>while</li>
137+
<li>with</li>
138+
<li>yield</li>
139+
</ul>
140+
141+
## FEATURE SET
142+
143+
144+
### Client Modification Feature
145+
| Name | Supported | Defined By |
146+
| ---- | --------- | ---------- |
147+
|BasePath|✓|ToolingExtension
148+
|Authorizations|✗|ToolingExtension
149+
|UserAgent|✗|ToolingExtension
150+
151+
### Data Type Feature
152+
| Name | Supported | Defined By |
153+
| ---- | --------- | ---------- |
154+
|Custom|✗|OAS2,OAS3
155+
|Int32|✓|OAS2,OAS3
156+
|Int64|✓|OAS2,OAS3
157+
|Float|✓|OAS2,OAS3
158+
|Double|✓|OAS2,OAS3
159+
|Decimal|✓|ToolingExtension
160+
|String|✓|OAS2,OAS3
161+
|Byte|✓|OAS2,OAS3
162+
|Binary|✓|OAS2,OAS3
163+
|Boolean|✓|OAS2,OAS3
164+
|Date|✓|OAS2,OAS3
165+
|DateTime|✓|OAS2,OAS3
166+
|Password|✓|OAS2,OAS3
167+
|File|✓|OAS2
168+
|Array|✓|OAS2,OAS3
169+
|Maps|✓|ToolingExtension
170+
|CollectionFormat|✓|OAS2
171+
|CollectionFormatMulti|✓|OAS2
172+
|Enum|✓|OAS2,OAS3
173+
|ArrayOfEnum|✓|ToolingExtension
174+
|ArrayOfModel|✓|ToolingExtension
175+
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
176+
|ArrayOfCollectionOfModel|✓|ToolingExtension
177+
|ArrayOfCollectionOfEnum|✓|ToolingExtension
178+
|MapOfEnum|✓|ToolingExtension
179+
|MapOfModel|✓|ToolingExtension
180+
|MapOfCollectionOfPrimitives|✓|ToolingExtension
181+
|MapOfCollectionOfModel|✓|ToolingExtension
182+
|MapOfCollectionOfEnum|✓|ToolingExtension
183+
184+
### Documentation Feature
185+
| Name | Supported | Defined By |
186+
| ---- | --------- | ---------- |
187+
|Readme|✓|ToolingExtension
188+
|Model|✓|ToolingExtension
189+
|Api|✓|ToolingExtension
190+
191+
### Global Feature
192+
| Name | Supported | Defined By |
193+
| ---- | --------- | ---------- |
194+
|Host|✓|OAS2,OAS3
195+
|BasePath|✓|OAS2,OAS3
196+
|Info|✓|OAS2,OAS3
197+
|Schemes|✗|OAS2,OAS3
198+
|PartialSchemes|✓|OAS2,OAS3
199+
|Consumes|✓|OAS2
200+
|Produces|✓|OAS2
201+
|ExternalDocumentation|✓|OAS2,OAS3
202+
|Examples|✓|OAS2,OAS3
203+
|XMLStructureDefinitions|✗|OAS2,OAS3
204+
|MultiServer|✗|OAS3
205+
|ParameterizedServer|✗|OAS3
206+
|ParameterStyling|✗|OAS3
207+
|Callbacks|✗|OAS3
208+
|LinkObjects|✗|OAS3
209+
210+
### Parameter Feature
211+
| Name | Supported | Defined By |
212+
| ---- | --------- | ---------- |
213+
|Path|✓|OAS2,OAS3
214+
|Query|✓|OAS2,OAS3
215+
|Header|✓|OAS2,OAS3
216+
|Body|✓|OAS2
217+
|FormUnencoded|✓|OAS2
218+
|FormMultipart|✓|OAS2
219+
|Cookie|✓|OAS3
220+
221+
### Schema Support Feature
222+
| Name | Supported | Defined By |
223+
| ---- | --------- | ---------- |
224+
|Simple|✓|OAS2,OAS3
225+
|Composite|✓|OAS2,OAS3
226+
|Polymorphism|✓|OAS2,OAS3
227+
|Union|✗|OAS3
228+
229+
### Security Feature
230+
| Name | Supported | Defined By |
231+
| ---- | --------- | ---------- |
232+
|BasicAuth|✗|OAS2,OAS3
233+
|ApiKey|✗|OAS2,OAS3
234+
|OpenIDConnect|✗|OAS3
235+
|BearerToken|✗|OAS3
236+
|OAuth2_Implicit|✗|OAS2,OAS3
237+
|OAuth2_Password|✗|OAS2,OAS3
238+
|OAuth2_ClientCredentials|✗|OAS2,OAS3
239+
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
240+
241+
### Wire Format Feature
242+
| Name | Supported | Defined By |
243+
| ---- | --------- | ---------- |
244+
|JSON|✓|OAS2,OAS3
245+
|XML|✓|OAS2,OAS3
246+
|PROTOBUF|✗|ToolingExtension
247+
|Custom|✗|OAS2,OAS3

0 commit comments

Comments
 (0)