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. 1937
      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.properties,
this.required, this.required,
this.items, this.items,
this.additionalProperties,
}); });
factory Schema.fromJson(final Map<String, dynamic> json) => _$SchemaFromJson(json); factory Schema.fromJson(final Map<String, dynamic> json) => _$SchemaFromJson(json);
@ -53,4 +54,6 @@ class Schema {
final List<String>? required; final List<String>? required;
final Schema? items; 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', 'enum',
'properties', 'properties',
'required', 'required',
'items' 'items',
'additionalProperties'
], ],
); );
return Schema( return Schema(
@ -41,6 +42,7 @@ Schema _$SchemaFromJson(Map<String, dynamic> json) {
), ),
required: (json['required'] as List<dynamic>?)?.map((e) => e as String).toList(), 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>), 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('properties', instance.properties?.map((k, e) => MapEntry(k, e.toJson())));
writeNotNull('required', instance.required); writeNotNull('required', instance.required);
writeNotNull('items', instance.items?.toJson()); writeNotNull('items', instance.items?.toJson());
writeNotNull('additionalProperties', instance.additionalProperties);
return val; return val;
} }

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

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

2
packages/nextcloud/build.yaml

@ -3,5 +3,5 @@ targets:
builders: builders:
json_serializable: json_serializable:
options: 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 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 // coverage:ignore-end
} }
@JsonSerializable() @JsonSerializable(disallowUnrecognizedKeys: false)
class CoreServerCapabilities_Ocs_Data_Capabilities { class CoreServerCapabilities_Ocs_Data_Capabilities {
CoreServerCapabilities_Ocs_Data_Capabilities({ CoreServerCapabilities_Ocs_Data_Capabilities({
required this.core, required this.core,
@ -3316,7 +3316,7 @@ class UserStatusClearAt_Time {
// coverage:ignore-end // coverage:ignore-end
} }
@JsonSerializable(disallowUnrecognizedKeys: true) @JsonSerializable()
class UserStatusClearAt { class UserStatusClearAt {
UserStatusClearAt({ UserStatusClearAt({
required this.type, required this.type,
@ -3549,7 +3549,7 @@ class UserStatus_ClearAt {
// coverage:ignore-end // coverage:ignore-end
} }
@JsonSerializable(disallowUnrecognizedKeys: true) @JsonSerializable()
class UserStatus { class UserStatus {
UserStatus({ UserStatus({
required this.userId, required this.userId,

1937
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": { "capabilities": {
"type": "object", "type": "object",
"additionalProperties": true,
"required": [ "required": [
"core", "core",
"bruteforce", "bruteforce",

1
specs/core.json

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

Loading…
Cancel
Save