Skip to content

Commit

Permalink
refs #4526 fixed a bug returning type objects for Swagger/OpenAPI arr…
Browse files Browse the repository at this point in the history
…ay types (#4527)
  • Loading branch information
davidnich committed May 14, 2022
1 parent c9688bc commit eb952ae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doxygen/lang/900_release_notes.dox.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- allow a logger to be set in validators
(<a href="https://github.com/qorelanguage/qore/issues/4509">issue 4509</a>)
- <a href="../../modules/SwaggerDataProvider/html/index.html">SwaggerDataProvider</a> module
- fixed a bug where array types failed due to missing item definitions
(<a href="https://github.com/qorelanguage/qore/issues/4526">issue 4526</a>)
- fixed a bug where \c object types in Swagger schemas could be converted directly to \c object types in %Qore
instead of \c hash
(<a href="https://github.com/qorelanguage/qore/issues/4520">issue 4520</a>)
Expand Down
2 changes: 1 addition & 1 deletion qlib/SwaggerDataProvider/SwaggerDataProvider.qc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public class SwaggerDataProvider inherits AbstractDataProvider {
pio.getOperation(name.lwr(), uri_path));
} catch (hash<ExceptionInfo> ex) {
if (ex.err != "INVALID-METHOD") {
rethrow;
rethrow ex.err, sprintf("%s (while resolving %y %y)", ex.desc, name, uri_path);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions qlib/SwaggerDataProvider/SwaggerDataProvider.qm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ module SwaggerDataProvider {
@section swaggerdataprovider_relnotes Release Notes

@subsection swaggerdataprovider_v1_2_1 SwaggerDataProvider v1.2.1
- fixed a bug where array types failed due to missing item definitions
(<a href="https://github.com/qorelanguage/qore/issues/4526">issue 4526</a>)
- fixed a bug where \c object types in Swagger schemas could be converted directly to \c object types in %Qore
instead of \c hash
(<a href="https://github.com/qorelanguage/qore/issues/4520">issue 4520</a>)
Expand Down
8 changes: 7 additions & 1 deletion qlib/SwaggerDataProvider/SwaggerDataProviderBase.qc
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ public class SwaggerDataProviderBase inherits AbstractDataProvider {
map type.addField(getFieldFromSchemaIntern(path + "/" + $1.key, $1.key, NOTHING, $1.value,
exists schema.required{$1.key})), schema.properties.pairIterator();
if (schema.additionalProperties) {
on_error printf("schema: %N\n", schema);
type.setDefaultOtherFieldType(getType(path + "/" + schema.additionalProperties.type,
schema.additionalProperties.type));
schema.additionalProperties.type, schema.additionalProperties.format,
schema.additionalProperties.items,
!schema.additionalProperties.nullable));
} else {
# make sure that extra fields are not supported
type.setDefaultOtherFieldType();
Expand Down Expand Up @@ -168,6 +171,9 @@ public class SwaggerDataProviderBase inherits AbstractDataProvider {
: new QoreSoftStringOrNothingDataType(type_options);

case "array":
if (!arrayItems) {
throw "SWAGGER-SCHEMA-ERROR", sprintf("no item definition for array path %y", path);
}
return new SoftListDataType(getSchemaDataType(path, arrayItems), !required);

case "object":
Expand Down

0 comments on commit eb952ae

Please sign in to comment.