Browse Source

Merge pull request #171 from provokateurin/fix/mappings

Fix mappings
pull/172/head
Kate 2 years ago committed by GitHub
parent
commit
c1ec108f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/dynamite/lib/src/openapi_builder.dart
  2. 2
      tool/generate-nextcloud.sh

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

@ -1383,7 +1383,10 @@ TypeResult resolveType(
if (schema.discriminator!.mapping != null && if (schema.discriminator!.mapping != null &&
schema.discriminator!.mapping!.isNotEmpty) ...[ schema.discriminator!.mapping!.isNotEmpty) ...[
for (final key in schema.discriminator!.mapping!.entries for (final key in schema.discriminator!.mapping!.entries
.where((final entry) => entry.value.endsWith('/${result.name}')) .where(
(final entry) =>
entry.value.endsWith('/${result.name.replaceFirst(state.prefix, '')}'),
)
.map((final entry) => entry.key)) ...[ .map((final entry) => entry.key)) ...[
" || data['${schema.discriminator!.propertyName}'] == '$key'", " || data['${schema.discriminator!.propertyName}'] == '$key'",
], ],

2
tool/generate-nextcloud.sh

@ -19,7 +19,7 @@ for i in $(seq 0 $((${#codenames[@]} - 1))); do
-s \ -s \
'.[] '.[]
| .components.schemas = (.components.schemas | with_entries(.key = if .key == "OCSMeta" or .key == "EmptyOCS" then .key else $prefix + .key end)) | .components.schemas = (.components.schemas | with_entries(.key = if .key == "OCSMeta" or .key == "EmptyOCS" then .key else $prefix + .key end))
| walk(if type == "object" and has("$ref") and ."$ref" != "#/components/schemas/OCSMeta" and ."$ref" != "#/components/schemas/EmptyOCS" then ."$ref" |= sub("^#/components/schemas/";"#/components/schemas/" + $prefix) else . end)' \ | walk(if type == "string" and . != "#/components/schemas/OCSMeta" and . != "#/components/schemas/EmptyOCS" then . |= sub("^#/components/schemas/";"#/components/schemas/" + $prefix) else . end)' \
/tmp/nextcloud-neon/"$codename".json \ /tmp/nextcloud-neon/"$codename".json \
> /tmp/nextcloud-neon/"$codename"-prefixed.json > /tmp/nextcloud-neon/"$codename"-prefixed.json

Loading…
Cancel
Save