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

Version/2.11.6 #655

Merged
merged 21 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions lib/src/code_generators/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const kPath = 'path';
const kOptionalBody = 'optionalBody';
const kFormData = 'formData';
const kMultipart = 'multipart';
const kDateTimeFormat = 'date-time';

const kDefaultBodyParameter = 'Object';
const kField = 'Field';
Expand Down Expand Up @@ -90,6 +91,8 @@ const kBody = 'body';
const kPartFile = 'partFile';
const kPart = 'part';

const kDateTimeType = 'DateTime';

const kDynamic = 'dynamic';

const supportedRequestTypes = ['get', 'post', 'put', 'delete', 'head', 'patch'];
Expand Down
19 changes: 17 additions & 2 deletions lib/src/code_generators/swagger_requests_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,17 @@ class SwaggerRequestsGenerator extends SwaggerGeneratorBase {
if (parameter.schema!.items != null || parameter.schema!.type == kArray) {
return (parameter.schema!.ref.getRef() + modelPostfix).asList();
}

final ref = parameter.schema?.ref;

if (ref != null) {
final neededSchema = root.allSchemas[ref.getUnformattedRef()];

if (kBasicTypesMap.containsKey(neededSchema?.type)) {
return kBasicTypesMap[neededSchema?.type]!;
}
}

return (parameter.schema!.ref.getRef() + modelPostfix);
} else if (parameter.schema?.type == kArray &&
parameter.schema?.items?.type.isNotEmpty == true) {
Expand All @@ -646,6 +657,10 @@ class SwaggerRequestsGenerator extends SwaggerGeneratorBase {
}

if (parameter.schema?.type.isNotEmpty == true) {
if (parameter.schema?.format == kDateTimeFormat) {
return kDateTimeType;
}

return _mapParameterName(parameter.schema!.type, format, modelPostfix);
}

Expand Down Expand Up @@ -1205,8 +1220,8 @@ class SwaggerRequestsGenerator extends SwaggerGeneratorBase {
final contentSchemaType = content.schema?.type ?? '';
if (contentSchemaType.isNotEmpty == true) {
if (contentSchemaType == 'string' &&
content.schema?.format == 'date-time') {
return 'DateTime';
content.schema?.format == kDateTimeFormat) {
return kDateTimeType;
}
return kBasicTypesMap[contentSchemaType];
}
Expand Down