Browse Source

dynamite,specs,nextcloud: Support additionalProperties

pull/133/head
jld3103 2 years ago
parent
commit
21aa8c679d
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 3
      packages/dynamite/lib/src/models/schema.dart
  2. 5
      packages/dynamite/lib/src/models/schema.g.dart
  3. 10
      packages/dynamite/lib/src/openapi_builder.dart
  4. 2
      packages/nextcloud/build.yaml
  5. 6
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  6. 997
      packages/nextcloud/lib/src/nextcloud.openapi.g.dart
  7. 1
      packages/nextcloud/lib/src/nextcloud.openapi.json
  8. 1
      specs/core.json

3
packages/dynamite/lib/src/models/schema.dart

@ -18,6 +18,7 @@ class Schema {
this.properties,
this.required,
this.items,
this.additionalProperties,
});
factory Schema.fromJson(final Map<String, dynamic> json) => _$SchemaFromJson(json);
@ -53,4 +54,6 @@ class Schema {
final List<String>? required;
final Schema? items;
final bool? additionalProperties;
}

5
packages/dynamite/lib/src/models/schema.g.dart

@ -22,7 +22,8 @@ Schema _$SchemaFromJson(Map<String, dynamic> json) {
'enum',
'properties',
'required',
'items'
'items',
'additionalProperties'
],
);
return Schema(
@ -41,6 +42,7 @@ Schema _$SchemaFromJson(Map<String, dynamic> json) {
),
required: (json['required'] as List<dynamic>?)?.map((e) => e as String).toList(),
items: json['items'] == null ? null : Schema.fromJson(json['items'] as Map<String, dynamic>),
additionalProperties: json['additionalProperties'] as bool?,
);
}
@ -66,5 +68,6 @@ Map<String, dynamic> _$SchemaToJson(Schema instance) {
writeNotNull('properties', instance.properties?.map((k, e) => MapEntry(k, e.toJson())));
writeNotNull('required', instance.required);
writeNotNull('items', instance.items?.toJson());
writeNotNull('additionalProperties', instance.additionalProperties);
return val;
}

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

@ -326,12 +326,7 @@ class OpenAPIBuilder implements Builder {
(final s) => resolveType(
'$identifier${schema.ofs!.indexOf(s)}',
s,
extraJsonSerializableValues: {
'disallowUnrecognizedKeys': 'true',
if (extraJsonSerializableValues != null) ...{
...extraJsonSerializableValues,
},
},
extraJsonSerializableValues: extraJsonSerializableValues,
),
)
.toList();
@ -518,6 +513,9 @@ class OpenAPIBuilder implements Builder {
refer('JsonSerializable').call(
[],
{
if (schema.additionalProperties ?? false) ...{
'disallowUnrecognizedKeys': refer('false'),
},
if (extraJsonSerializableValues != null) ...{
for (final key in extraJsonSerializableValues.keys) ...{
key: refer(extraJsonSerializableValues[key]!),

2
packages/nextcloud/build.yaml

@ -3,5 +3,5 @@ targets:
builders:
json_serializable:
options:
# disallow_unrecognized_keys: true # Uncomment this to check that all the models are correct. We can't enable this because the capabilities contain different keys based on which apps are installed
disallow_unrecognized_keys: true
explicit_to_json: true

6
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -1247,7 +1247,7 @@ class CoreServerCapabilities_Ocs_Data_Capabilities_WeatherStatus {
// coverage:ignore-end
}
@JsonSerializable()
@JsonSerializable(disallowUnrecognizedKeys: false)
class CoreServerCapabilities_Ocs_Data_Capabilities {
CoreServerCapabilities_Ocs_Data_Capabilities({
required this.core,
@ -3316,7 +3316,7 @@ class UserStatusClearAt_Time {
// coverage:ignore-end
}
@JsonSerializable(disallowUnrecognizedKeys: true)
@JsonSerializable()
class UserStatusClearAt {
UserStatusClearAt({
required this.type,
@ -3549,7 +3549,7 @@ class UserStatus_ClearAt {
// coverage:ignore-end
}
@JsonSerializable(disallowUnrecognizedKeys: true)
@JsonSerializable()
class UserStatus {
UserStatus({
required this.userId,

997
packages/nextcloud/lib/src/nextcloud.openapi.g.dart

File diff suppressed because it is too large Load Diff

1
packages/nextcloud/lib/src/nextcloud.openapi.json

@ -190,6 +190,7 @@
},
"capabilities": {
"type": "object",
"additionalProperties": true,
"required": [
"core",
"bruteforce",

1
specs/core.json

@ -176,6 +176,7 @@
},
"capabilities": {
"type": "object",
"additionalProperties": true,
"required": [
"core",
"bruteforce",

Loading…
Cancel
Save