Browse Source

Merge pull request #133 from provokateurin/feature/additional-properties

dynamite,specs,nextcloud: Support additionalProperties
pull/134/head
Kate 2 years ago committed by GitHub
parent
commit
b4d23a2118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 13
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  6. 1939
      packages/nextcloud/lib/src/nextcloud.openapi.g.dart
  7. 10
      packages/nextcloud/lib/src/nextcloud.openapi.json
  8. 10
      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

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

@ -290,13 +290,18 @@ class CoreServerCapabilities_Ocs_Data_Capabilities_Bruteforce {
@JsonSerializable()
class CoreServerCapabilities_Ocs_Data_Capabilities_MetadataAvailable {
CoreServerCapabilities_Ocs_Data_Capabilities_MetadataAvailable({required this.size});
CoreServerCapabilities_Ocs_Data_Capabilities_MetadataAvailable({
required this.size,
required this.gps,
});
factory CoreServerCapabilities_Ocs_Data_Capabilities_MetadataAvailable.fromJson(Map<String, dynamic> json) =>
_$CoreServerCapabilities_Ocs_Data_Capabilities_MetadataAvailableFromJson(json);
final List<String> size;
final List<String> gps;
// coverage:ignore-start
Map<String, dynamic> toJson() => _$CoreServerCapabilities_Ocs_Data_Capabilities_MetadataAvailableToJson(this);
// coverage:ignore-end
@ -1247,7 +1252,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 +3321,7 @@ class UserStatusClearAt_Time {
// coverage:ignore-end
}
@JsonSerializable(disallowUnrecognizedKeys: true)
@JsonSerializable()
class UserStatusClearAt {
UserStatusClearAt({
required this.type,
@ -3549,7 +3554,7 @@ class UserStatus_ClearAt {
// coverage:ignore-end
}
@JsonSerializable(disallowUnrecognizedKeys: true)
@JsonSerializable()
class UserStatus {
UserStatus({
required this.userId,

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

File diff suppressed because it is too large Load Diff

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

@ -190,6 +190,7 @@
},
"capabilities": {
"type": "object",
"additionalProperties": true,
"required": [
"core",
"bruteforce",
@ -236,7 +237,8 @@
"metadataAvailable": {
"type": "object",
"required": [
"size"
"size",
"gps"
],
"properties": {
"size": {
@ -244,6 +246,12 @@
"items": {
"type": "string"
}
},
"gps": {
"type": "array",
"items": {
"type": "string"
}
}
}
},

10
specs/core.json

@ -176,6 +176,7 @@
},
"capabilities": {
"type": "object",
"additionalProperties": true,
"required": [
"core",
"bruteforce",
@ -222,7 +223,8 @@
"metadataAvailable": {
"type": "object",
"required": [
"size"
"size",
"gps"
],
"properties": {
"size": {
@ -230,6 +232,12 @@
"items": {
"type": "string"
}
},
"gps": {
"type": "array",
"items": {
"type": "string"
}
}
}
},

Loading…
Cancel
Save