Skip to content

Commit de8b344

Browse files
authored
[dart] Generic docs update and fixes (#8999)
* [dart] Generic docs update and fixes * none of the dart generators supports XML * jaguar is no longer maintained * dart and dart-dio support bearer token * none of the dart generators supports composition atm. * [dart-dio] Supports customization of authorizations and userAgent * Remove deprecation of dart-jaguar for now
1 parent c920d08 commit de8b344

10 files changed

Lines changed: 45 additions & 28 deletions

File tree

docs/generators/dart-dio.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
135135
| Name | Supported | Defined By |
136136
| ---- | --------- | ---------- |
137137
|BasePath|✓|ToolingExtension
138-
|Authorizations||ToolingExtension
139-
|UserAgent||ToolingExtension
138+
|Authorizations||ToolingExtension
139+
|UserAgent||ToolingExtension
140140
|MockServer|✗|ToolingExtension
141141

142142
### Data Type Feature
@@ -213,7 +213,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
213213
| Name | Supported | Defined By |
214214
| ---- | --------- | ---------- |
215215
|Simple|✓|OAS2,OAS3
216-
|Composite||OAS2,OAS3
216+
|Composite||OAS2,OAS3
217217
|Polymorphism|✗|OAS2,OAS3
218218
|Union|✗|OAS3
219219

@@ -223,7 +223,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
223223
|BasicAuth|✓|OAS2,OAS3
224224
|ApiKey|✓|OAS2,OAS3
225225
|OpenIDConnect|✗|OAS3
226-
|BearerToken||OAS3
226+
|BearerToken||OAS3
227227
|OAuth2_Implicit|✓|OAS2,OAS3
228228
|OAuth2_Password|✗|OAS2,OAS3
229229
|OAuth2_ClientCredentials|✗|OAS2,OAS3
@@ -233,6 +233,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
233233
| Name | Supported | Defined By |
234234
| ---- | --------- | ---------- |
235235
|JSON|✓|OAS2,OAS3
236-
|XML||OAS2,OAS3
236+
|XML||OAS2,OAS3
237237
|PROTOBUF|✗|ToolingExtension
238238
|Custom|✗|OAS2,OAS3

docs/generators/dart-jaguar.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
208208
| Name | Supported | Defined By |
209209
| ---- | --------- | ---------- |
210210
|Simple|✓|OAS2,OAS3
211-
|Composite||OAS2,OAS3
211+
|Composite||OAS2,OAS3
212212
|Polymorphism|✗|OAS2,OAS3
213213
|Union|✗|OAS3
214214

@@ -228,6 +228,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
228228
| Name | Supported | Defined By |
229229
| ---- | --------- | ---------- |
230230
|JSON|✓|OAS2,OAS3
231-
|XML||OAS2,OAS3
232-
|PROTOBUF||ToolingExtension
231+
|XML||OAS2,OAS3
232+
|PROTOBUF||ToolingExtension
233233
|Custom|✗|OAS2,OAS3

docs/generators/dart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
207207
| Name | Supported | Defined By |
208208
| ---- | --------- | ---------- |
209209
|Simple|✓|OAS2,OAS3
210-
|Composite||OAS2,OAS3
210+
|Composite||OAS2,OAS3
211211
|Polymorphism|✗|OAS2,OAS3
212212
|Union|✗|OAS3
213213

@@ -217,7 +217,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
217217
|BasicAuth|✓|OAS2,OAS3
218218
|ApiKey|✓|OAS2,OAS3
219219
|OpenIDConnect|✗|OAS3
220-
|BearerToken||OAS3
220+
|BearerToken||OAS3
221221
|OAuth2_Implicit|✓|OAS2,OAS3
222222
|OAuth2_Password|✗|OAS2,OAS3
223223
|OAuth2_ClientCredentials|✗|OAS2,OAS3
@@ -227,6 +227,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
227227
| Name | Supported | Defined By |
228228
| ---- | --------- | ---------- |
229229
|JSON|✓|OAS2,OAS3
230-
|XML||OAS2,OAS3
230+
|XML||OAS2,OAS3
231231
|PROTOBUF|✗|ToolingExtension
232232
|Custom|✗|OAS2,OAS3

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public AbstractDartCodegen() {
6363
.securityFeatures(EnumSet.of(
6464
SecurityFeature.OAuth2_Implicit,
6565
SecurityFeature.BasicAuth,
66+
SecurityFeature.BearerToken,
6667
SecurityFeature.ApiKey
6768
))
6869
.excludeGlobalFeatures(
@@ -72,14 +73,19 @@ public AbstractDartCodegen() {
7273
GlobalFeature.ParameterStyling
7374
)
7475
.excludeSchemaSupportFeatures(
75-
SchemaSupportFeature.Polymorphism
76+
SchemaSupportFeature.Polymorphism,
77+
SchemaSupportFeature.Union,
78+
SchemaSupportFeature.Composite
7679
)
7780
.includeParameterFeatures(
7881
ParameterFeature.Cookie
7982
)
8083
.includeClientModificationFeatures(
8184
ClientModificationFeature.BasePath
8285
)
86+
.excludeWireFormatFeatures(
87+
WireFormatFeature.XML
88+
)
8389
);
8490

8591
outputFolder = "generated-code/dart";

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.swagger.v3.oas.models.media.Schema;
2323
import org.apache.commons.lang3.StringUtils;
2424
import org.openapitools.codegen.*;
25+
import org.openapitools.codegen.meta.features.ClientModificationFeature;
2526
import org.openapitools.codegen.utils.ModelUtils;
2627
import org.openapitools.codegen.utils.ProcessUtils;
2728
import org.slf4j.Logger;
@@ -46,6 +47,14 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
4647

4748
public DartDioClientCodegen() {
4849
super();
50+
51+
modifyFeatureSet(features -> features
52+
.includeClientModificationFeatures(
53+
ClientModificationFeature.Authorizations,
54+
ClientModificationFeature.UserAgent
55+
)
56+
);
57+
4958
outputFolder = "generated-code/dart-dio";
5059
embeddedTemplateDir = "dart-dio";
5160
this.setTemplateDir(embeddedTemplateDir);

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.openapitools.codegen.languages;
1818

1919
import org.openapitools.codegen.*;
20+
import org.openapitools.codegen.meta.GeneratorMetadata;
21+
import org.openapitools.codegen.meta.Stability;
2022
import org.openapitools.codegen.meta.features.*;
2123
import org.openapitools.codegen.utils.ModelUtils;
2224

@@ -79,6 +81,10 @@ public DartJaguarClientCodegen() {
7981
.includeParameterFeatures(
8082
ParameterFeature.Cookie
8183
)
84+
.wireFormatFeatures(EnumSet.of(
85+
WireFormatFeature.JSON,
86+
WireFormatFeature.PROTOBUF
87+
))
8288
.includeClientModificationFeatures(
8389
ClientModificationFeature.BasePath
8490
)

modules/openapi-generator/src/main/resources/dart-dio/auth/auth.mustache

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
import 'package:dio/dio.dart';
33

44
abstract class AuthInterceptor extends Interceptor {
5-
/*
6-
* Get auth information on given route for the given type
7-
* Can return null if type is not present on auth data or if route doesn't need authentication
8-
*/
5+
/// Get auth information on given route for the given type.
6+
/// Can return an empty list if type is not present on auth data or
7+
/// if route doesn't need authentication.
98
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
109
if (route.extra.containsKey('secure')) {
1110
final auth = route.extra['secure'] as List<Map<String, String>>;

samples/client/petstore/dart-dio/petstore_client_lib/lib/auth/auth.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import 'package:dio/dio.dart';
99

1010
abstract class AuthInterceptor extends Interceptor {
11-
/*
12-
* Get auth information on given route for the given type
13-
* Can return null if type is not present on auth data or if route doesn't need authentication
14-
*/
11+
/// Get auth information on given route for the given type.
12+
/// Can return an empty list if type is not present on auth data or
13+
/// if route doesn't need authentication.
1514
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
1615
if (route.extra.containsKey('secure')) {
1716
final auth = route.extra['secure'] as List<Map<String, String>>;

samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/auth/auth.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import 'package:dio/dio.dart';
99

1010
abstract class AuthInterceptor extends Interceptor {
11-
/*
12-
* Get auth information on given route for the given type
13-
* Can return null if type is not present on auth data or if route doesn't need authentication
14-
*/
11+
/// Get auth information on given route for the given type.
12+
/// Can return an empty list if type is not present on auth data or
13+
/// if route doesn't need authentication.
1514
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
1615
if (route.extra.containsKey('secure')) {
1716
final auth = route.extra['secure'] as List<Map<String, String>>;

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/auth/auth.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import 'package:dio/dio.dart';
99

1010
abstract class AuthInterceptor extends Interceptor {
11-
/*
12-
* Get auth information on given route for the given type
13-
* Can return null if type is not present on auth data or if route doesn't need authentication
14-
*/
11+
/// Get auth information on given route for the given type.
12+
/// Can return an empty list if type is not present on auth data or
13+
/// if route doesn't need authentication.
1514
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
1615
if (route.extra.containsKey('secure')) {
1716
final auth = route.extra['secure'] as List<Map<String, String>>;

0 commit comments

Comments
 (0)