Browse Source

Merge pull request #220 from provokateurin/fix/dynamite-skip-default-values

dynamite: Only skip default values in query parameters
pull/223/head
Kate 2 years ago committed by GitHub
parent
commit
67b7b04d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/dynamite/lib/src/openapi_builder.dart

4
packages/dynamite/lib/src/openapi_builder.dart

@ -667,7 +667,7 @@ class OpenAPIBuilder implements Builder {
// Objects inside the query always have to be interpreted in some way // Objects inside the query always have to be interpreted in some way
mimeType: 'application/json', mimeType: 'application/json',
); );
if (defaultValueCode != null && parameter.in_ != 'path') { if (defaultValueCode != null && parameter.in_ == 'query') {
code.write('if (${_toDartName(parameter.name)} != $defaultValueCode) {'); code.write('if (${_toDartName(parameter.name)} != $defaultValueCode) {');
} }
switch (parameter.in_) { switch (parameter.in_) {
@ -689,7 +689,7 @@ class OpenAPIBuilder implements Builder {
default: default:
throw Exception('Can not work with parameter in "${parameter.in_}"'); throw Exception('Can not work with parameter in "${parameter.in_}"');
} }
if (defaultValueCode != null) { if (defaultValueCode != null && parameter.in_ == 'query') {
code.write('}'); code.write('}');
} }
if (nullable) { if (nullable) {

Loading…
Cancel
Save