forked from loafle/openapi-generator-original
[dart-dio] Correctly serialize path parameters (#14666)
This commit is contained in:
parent
8c1f4b1a62
commit
bca80c0d3d
@ -83,7 +83,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.Authorizations,
|
||||
ClientModificationFeature.UserAgent
|
||||
).includeSchemaSupportFeatures(
|
||||
).includeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.Polymorphism,
|
||||
SchemaSupportFeature.Union,
|
||||
SchemaSupportFeature.Composite,
|
||||
@ -277,7 +277,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
imports.put("Uint8List", "dart:typed_data");
|
||||
imports.put("MultipartFile", DIO_IMPORT);
|
||||
}
|
||||
|
||||
|
||||
private void configureDateLibrary(String srcFolder) {
|
||||
switch (dateLibrary) {
|
||||
case DATE_LIBRARY_TIME_MACHINE:
|
||||
@ -364,12 +364,12 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenModel model : allModels.values()) {
|
||||
for (CodegenModel model : allModels.values()) {
|
||||
syncRootTypesWithInnerVars(allModels, model);
|
||||
}
|
||||
}
|
||||
private void syncRootTypesWithInnerVars(Map<String, CodegenModel> objs, CodegenModel model) {
|
||||
List<CodegenProperty> allVars = new ArrayList<>();
|
||||
List<CodegenProperty> allVars = new ArrayList<>();
|
||||
allVars.addAll(((Collection<CodegenProperty>) model.vendorExtensions.get(kSelfAndAncestorOnlyProps)));
|
||||
allVars.addAll(((Collection<CodegenProperty>) model.vendorExtensions.get(kSelfOnlyProps)));
|
||||
allVars.addAll(((Collection<CodegenProperty>) model.vendorExtensions.get(kAncestorOnlyProps)));
|
||||
@ -383,8 +383,8 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
//fill the property's VendorExtensions with the type's VendorExtensions
|
||||
prop.getVendorExtensions().put(kIsParent, relatedModel.getVendorExtensions().get(kIsParent));
|
||||
prop.isEnum = relatedModel.isEnum;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private final String kIsChild = "x-is-child";
|
||||
@ -397,7 +397,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
private final String kSelfAndAncestorOnlyProps = "x-self-and-ancestor-only-props";
|
||||
private final String kHasSelfAndAncestorOnlyProps = "x-has-self-and-ancestor-only-props";
|
||||
private final String kParentDiscriminator = "x-parent-discriminator";
|
||||
|
||||
|
||||
// adapts codegen models and property to dart rules of inheritance
|
||||
private void adaptToDartInheritance(Map<String, ModelsMap> objs) {
|
||||
// get all models
|
||||
@ -425,7 +425,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
allAncestorsForAllModelsFlat.addAll(allAncestors);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Set<String> allPureClasses = new HashSet<>();
|
||||
// set isChild,isParent,isPure
|
||||
@ -546,11 +546,11 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
/// override the default behavior of createDiscriminator
|
||||
/// to remove extra mappings added as a side effect of setLegacyDiscriminatorBehavior(false)
|
||||
/// override the default behavior of createDiscriminator
|
||||
/// to remove extra mappings added as a side effect of setLegacyDiscriminatorBehavior(false)
|
||||
/// this ensures 1-1 schema mapping instead of 1-many
|
||||
@Override
|
||||
protected CodegenDiscriminator createDiscriminator(String schemaName, Schema schema, OpenAPI openAPI) {
|
||||
protected CodegenDiscriminator createDiscriminator(String schemaName, Schema schema, OpenAPI openAPI) {
|
||||
CodegenDiscriminator sub = super.createDiscriminator(schemaName, schema, openAPI);
|
||||
Discriminator originalDiscriminator = schema.getDiscriminator();
|
||||
if (originalDiscriminator!=null) {
|
||||
@ -566,7 +566,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sub;
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library) && (op.getHasFormParams() || op.getHasQueryParams())) {
|
||||
if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library) && (op.getHasFormParams() || op.getHasQueryParams() || op.getHasPathParams())) {
|
||||
resultImports.add("package:" + pubName + "/" + sourceFolder + "/api_util.dart");
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class {{classname}} {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'{{{path}}}'{{#pathParams}}.replaceAll('{' r'{{{baseName}}}' '}', {{{paramName}}}.toString()){{/pathParams}};
|
||||
final _path = r'{{{path}}}'{{#pathParams}}.replaceAll('{' r'{{{baseName}}}' '}', {{#includeLibraryTemplate}}api/query_param{{/includeLibraryTemplate}}.toString()){{/pathParams}};
|
||||
final _options = Options(
|
||||
method: r'{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}',
|
||||
{{#isResponseFile}}
|
||||
|
@ -117,7 +117,7 @@ class PetApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString());
|
||||
final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', encodeQueryParameter(_serializers, petId, const FullType(int)).toString());
|
||||
final _options = Options(
|
||||
method: r'DELETE',
|
||||
headers: <String, dynamic>{
|
||||
@ -341,7 +341,7 @@ class PetApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString());
|
||||
final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', encodeQueryParameter(_serializers, petId, const FullType(int)).toString());
|
||||
final _options = Options(
|
||||
method: r'GET',
|
||||
headers: <String, dynamic>{
|
||||
@ -499,7 +499,7 @@ class PetApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString());
|
||||
final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', encodeQueryParameter(_serializers, petId, const FullType(int)).toString());
|
||||
final _options = Options(
|
||||
method: r'POST',
|
||||
headers: <String, dynamic>{
|
||||
@ -577,7 +577,7 @@ class PetApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/pet/{petId}/uploadImage'.replaceAll('{' r'petId' '}', petId.toString());
|
||||
final _path = r'/pet/{petId}/uploadImage'.replaceAll('{' r'petId' '}', encodeQueryParameter(_serializers, petId, const FullType(int)).toString());
|
||||
final _options = Options(
|
||||
method: r'POST',
|
||||
headers: <String, dynamic>{
|
||||
@ -683,7 +683,7 @@ class PetApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/fake/{petId}/uploadImageWithRequiredFile'.replaceAll('{' r'petId' '}', petId.toString());
|
||||
final _path = r'/fake/{petId}/uploadImageWithRequiredFile'.replaceAll('{' r'petId' '}', encodeQueryParameter(_serializers, petId, const FullType(int)).toString());
|
||||
final _options = Options(
|
||||
method: r'POST',
|
||||
headers: <String, dynamic>{
|
||||
|
@ -8,6 +8,7 @@ import 'package:built_value/serializer.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:openapi/src/api_util.dart';
|
||||
import 'package:openapi/src/model/order.dart';
|
||||
|
||||
class StoreApi {
|
||||
@ -41,7 +42,7 @@ class StoreApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/store/order/{order_id}'.replaceAll('{' r'order_id' '}', orderId.toString());
|
||||
final _path = r'/store/order/{order_id}'.replaceAll('{' r'order_id' '}', encodeQueryParameter(_serializers, orderId, const FullType(String)).toString());
|
||||
final _options = Options(
|
||||
method: r'DELETE',
|
||||
headers: <String, dynamic>{
|
||||
@ -168,7 +169,7 @@ class StoreApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/store/order/{order_id}'.replaceAll('{' r'order_id' '}', orderId.toString());
|
||||
final _path = r'/store/order/{order_id}'.replaceAll('{' r'order_id' '}', encodeQueryParameter(_serializers, orderId, const FullType(int)).toString());
|
||||
final _options = Options(
|
||||
method: r'GET',
|
||||
headers: <String, dynamic>{
|
||||
|
@ -243,7 +243,7 @@ class UserApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString());
|
||||
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', encodeQueryParameter(_serializers, username, const FullType(String)).toString());
|
||||
final _options = Options(
|
||||
method: r'DELETE',
|
||||
headers: <String, dynamic>{
|
||||
@ -290,7 +290,7 @@ class UserApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString());
|
||||
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', encodeQueryParameter(_serializers, username, const FullType(String)).toString());
|
||||
final _options = Options(
|
||||
method: r'GET',
|
||||
headers: <String, dynamic>{
|
||||
@ -492,7 +492,7 @@ class UserApi {
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
}) async {
|
||||
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString());
|
||||
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', encodeQueryParameter(_serializers, username, const FullType(String)).toString());
|
||||
final _options = Options(
|
||||
method: r'PUT',
|
||||
headers: <String, dynamic>{
|
||||
|
Loading…
x
Reference in New Issue
Block a user