Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine javascript and javascript-apollo generators #13270

Merged
merged 25 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
14cf893
Combine javascript and javascript-apollo generator functionality
joaomlneto Aug 24, 2022
0ef2cfb
Combine javascript and javascript-apollo templates
joaomlneto Aug 24, 2022
eeb7f25
update configs
joaomlneto Aug 24, 2022
8a94f88
deprecate javascript-apollo generator
joaomlneto Aug 24, 2022
d94e86f
bonus magic string deletion :sparkles:
joaomlneto Aug 24, 2022
a0965ed
update samples
joaomlneto Aug 24, 2022
6aa52c6
update generator docs
joaomlneto Aug 24, 2022
c15dc10
fix: include .babelrc in apollo generation
joaomlneto Aug 24, 2022
e33fdbc
update samples
joaomlneto Aug 24, 2022
7685145
Merge branch 'OpenAPITools:master' into combine-apollo-generator
joaomlneto Aug 24, 2022
7423d3a
update samples
joaomlneto Aug 24, 2022
3e44113
rename javascript-apollo to javascript-apollo-deprecated
joaomlneto Aug 25, 2022
05d8e39
fix javascript apollo library template
joaomlneto Aug 25, 2022
fc813c4
update samples
joaomlneto Aug 25, 2022
d4a644a
Create javascript-apollo-deprecated.md
joaomlneto Aug 25, 2022
6889903
Updated javascript generator template's gitignore
joaomlneto Aug 25, 2022
a4ed1c6
javascript generator: merge api_test template files
joaomlneto Aug 25, 2022
f7f85dd
update docs
joaomlneto Aug 25, 2022
49c5544
Merge branch 'OpenAPITools:master' into combine-apollo-generator
joaomlneto Aug 26, 2022
90b5707
cleanup
joaomlneto Aug 26, 2022
532b493
avoid possible config clash
joaomlneto Aug 26, 2022
a1aec3f
update javascript-apollo sample
joaomlneto Aug 26, 2022
e8b4299
update javascript-es6 sample
joaomlneto Aug 26, 2022
8070b40
update javascript-promise-es6 sample
joaomlneto Aug 26, 2022
193aa32
update samples
joaomlneto Aug 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bin/configs/javascript-apollo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
generatorName: javascript
outputDir: samples/client/petstore/javascript-apollo
library: apollo
inputSpec: modules/openapi-generator/src/test/resources/3_0/javascript/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/Javascript
additionalProperties:
appName: PetstoreClient
3 changes: 2 additions & 1 deletion bin/configs/javascript-es6.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
generatorName: javascript
outputDir: samples/client/petstore/javascript-es6
library: javascript
inputSpec: modules/openapi-generator/src/test/resources/3_0/javascript/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/Javascript/es6
templateDir: modules/openapi-generator/src/main/resources/Javascript
additionalProperties:
appName: PetstoreClient
3 changes: 2 additions & 1 deletion bin/configs/javascript-promise-es6.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
generatorName: javascript
outputDir: samples/client/petstore/javascript-promise-es6
library: javascript
inputSpec: modules/openapi-generator/src/test/resources/3_0/javascript/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/Javascript/es6
templateDir: modules/openapi-generator/src/main/resources/Javascript
additionalProperties:
usePromises: "true"
appName: PetstoreClient
2 changes: 1 addition & 1 deletion bin/configs/unmaintained/javascript-apollo.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generatorName: javascript-apollo
outputDir: samples/client/petstore/javascript-apollo
outputDir: samples/client/petstore/javascript-apollo-unmaintained
wing328 marked this conversation as resolved.
Show resolved Hide resolved
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Javascript-Apollo
additionalProperties:
Expand Down
2 changes: 1 addition & 1 deletion docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The following generators are available:
* [java](generators/java.md)
* [java-micronaut-client (beta)](generators/java-micronaut-client.md)
* [javascript](generators/javascript.md)
* [javascript-apollo](generators/javascript-apollo.md)
* [javascript-apollo-deprecated (deprecated)](generators/javascript-apollo-deprecated.md)
* [javascript-closure-angular](generators/javascript-closure-angular.md)
* [javascript-flowtyped](generators/javascript-flowtyped.md)
* [jaxrs-cxf-client](generators/jaxrs-cxf-client.md)
Expand Down
274 changes: 274 additions & 0 deletions docs/generators/javascript-apollo-deprecated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
---
title: Documentation for the javascript-apollo-deprecated Generator
---

## METADATA

| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | javascript-apollo-deprecated | pass this to the generate command after -g |
| generator stability | DEPRECATED | |
| generator type | CLIENT | |
| generator language | Javascript | |
| generator default templating engine | mustache | |
| helpTxt | Generates a JavaScript client library (beta) using Apollo RESTDatasource. | |

## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.

| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|apiPackage|package for generated api classes| |null|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|emitJSDoc|generate JSDoc comments| |true|
|emitModelMethods|generate getters and setters for model properties| |false|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|invokerPackage|root package for generated code| |null|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|licenseName|name of the license the project uses (Default: using info.license.name)| |null|
|modelPackage|package for generated models| |null|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|moduleName|module name for AMD, Node or globals (Default: generated from &lt;projectName&gt;)| |null|
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|projectDescription|description of the project (Default: using info.description or &quot;Client library of &lt;projectName&gt;&quot;)| |null|
|projectName|name of the project (Default: generated from info.title or &quot;openapi-js-client&quot;)| |null|
|projectVersion|version of the project (Default: using info.version or &quot;1.0.0&quot;)| |null|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src|
|useInheritance|use JavaScript prototype chains &amp; delegation for inheritance| |true|
|usePromises|use Promises as return values from the client API, instead of superagent callbacks| |false|

## IMPORT MAPPING

| Type/Alias | Imports |
| ---------- | ------- |


## INSTANTIATION TYPES

| Type/Alias | Instantiated By |
| ---------- | --------------- |
|array|Array|
|list|Array|
|map|Object|
|set|Array|


## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>Array</li>
<li>Blob</li>
<li>Boolean</li>
<li>Date</li>
<li>File</li>
<li>Number</li>
<li>Object</li>
<li>String</li>
</ul>

## RESERVED WORDS

<ul class="column-ul">
<li>Array</li>
<li>Date</li>
<li>Infinity</li>
<li>Math</li>
<li>NaN</li>
<li>Number</li>
<li>Object</li>
<li>String</li>
<li>abstract</li>
<li>arguments</li>
<li>boolean</li>
<li>break</li>
<li>byte</li>
<li>case</li>
<li>catch</li>
<li>char</li>
<li>class</li>
<li>const</li>
<li>continue</li>
<li>debugger</li>
<li>default</li>
<li>delete</li>
<li>do</li>
<li>double</li>
<li>else</li>
<li>enum</li>
<li>eval</li>
<li>export</li>
<li>extends</li>
<li>false</li>
<li>final</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>function</li>
<li>goto</li>
<li>hasOwnProperty</li>
<li>if</li>
<li>implements</li>
<li>import</li>
<li>in</li>
<li>instanceof</li>
<li>int</li>
<li>interface</li>
<li>isFinite</li>
<li>isNaN</li>
<li>isPrototypeOf</li>
<li>let</li>
<li>long</li>
<li>native</li>
<li>new</li>
<li>null</li>
<li>package</li>
<li>private</li>
<li>protected</li>
<li>prototype</li>
<li>public</li>
<li>return</li>
<li>short</li>
<li>static</li>
<li>super</li>
<li>switch</li>
<li>synchronized</li>
<li>this</li>
<li>throw</li>
<li>throws</li>
<li>toString</li>
<li>transient</li>
<li>true</li>
<li>try</li>
<li>typeof</li>
<li>undefined</li>
<li>valueOf</li>
<li>var</li>
<li>void</li>
<li>volatile</li>
<li>while</li>
<li>with</li>
<li>yield</li>
</ul>

## FEATURE SET


### Client Modification Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✗|ToolingExtension
|Authorizations|✗|ToolingExtension
|UserAgent|✗|ToolingExtension
|MockServer|✗|ToolingExtension

### Data Type Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Custom|✗|OAS2,OAS3
|Int32|✓|OAS2,OAS3
|Int64|✓|OAS2,OAS3
|Float|✓|OAS2,OAS3
|Double|✓|OAS2,OAS3
|Decimal|✓|ToolingExtension
|String|✓|OAS2,OAS3
|Byte|✓|OAS2,OAS3
|Binary|✓|OAS2,OAS3
|Boolean|✓|OAS2,OAS3
|Date|✓|OAS2,OAS3
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid|✗|
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3
|Object|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum|✓|OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|ArrayOfCollectionOfModel|✓|ToolingExtension
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|MapOfEnum|✓|ToolingExtension
|MapOfModel|✓|ToolingExtension
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|MapOfCollectionOfModel|✓|ToolingExtension
|MapOfCollectionOfEnum|✓|ToolingExtension

### Documentation Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Readme|✓|ToolingExtension
|Model|✓|ToolingExtension
|Api|✓|ToolingExtension

### Global Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Host|✓|OAS2,OAS3
|BasePath|✓|OAS2,OAS3
|Info|✓|OAS2,OAS3
|Schemes|✗|OAS2,OAS3
|PartialSchemes|✓|OAS2,OAS3
|Consumes|✓|OAS2
|Produces|✓|OAS2
|ExternalDocumentation|✓|OAS2,OAS3
|Examples|✓|OAS2,OAS3
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✗|OAS3
|ParameterStyling|✗|OAS3
|Callbacks|✓|OAS3
|LinkObjects|✗|OAS3

### Parameter Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Path|✓|OAS2,OAS3
|Query|✓|OAS2,OAS3
|Header|✓|OAS2,OAS3
|Body|✓|OAS2
|FormUnencoded|✓|OAS2
|FormMultipart|✓|OAS2
|Cookie|✓|OAS3

### Schema Support Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism|✓|OAS2,OAS3
|Union|✗|OAS3
|allOf|✗|OAS2,OAS3
|anyOf|✗|OAS3
|oneOf|✗|OAS3
|not|✗|OAS3

### Security Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
|BearerToken|✓|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✓|OAS2,OAS3
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|OAuth2_AuthorizationCode|✓|OAS2,OAS3

### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3
2 changes: 1 addition & 1 deletion docs/generators/javascript-apollo.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: Documentation for the javascript-apollo Generator
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | javascript-apollo | pass this to the generate command after -g |
| generator stability | STABLE | |
| generator stability | DEPRECATED | |
| generator type | CLIENT | |
| generator language | Javascript | |
| generator default templating engine | mustache | |
Expand Down
1 change: 1 addition & 0 deletions docs/generators/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|invokerPackage|root package for generated code| |null|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template)|<dl><dt>**javascript**</dt><dd>JavaScript client library</dd><dt>**apollo**</dt><dd>Apollo REST DataSource</dd></dl>|javascript|
|licenseName|name of the license the project uses (Default: using info.license.name)| |null|
|modelPackage|package for generated models| |null|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5936,7 +5936,7 @@ protected CliOption buildLibraryCliOption(Map<String, String> supportedLibraries
for (String lib : supportedLibraries.keySet()) {
sb.append("\n").append(lib).append(" - ").append(supportedLibraries.get(lib));
}
return new CliOption("library", sb.toString());
return new CliOption(CodegenConstants.LIBRARY, sb.toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public JavascriptApolloClientCodegen() {

modifyFeatureSet(features -> features.includeDocumentationFeatures(DocumentationFeature.Readme));

generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.DEPRECATED)
.build();

joaomlneto marked this conversation as resolved.
Show resolved Hide resolved
outputFolder = "generated-code/js";
modelTemplateFiles.put("model.mustache", ".js");
modelTestTemplateFiles.put("model_test.mustache", ".js");
Expand Down Expand Up @@ -217,7 +221,7 @@ public CodegenType getTag() {

@Override
public String getName() {
return "javascript-apollo";
return "javascript-apollo-deprecated";
}

@Override
Expand Down
Loading