Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [dart-dio] "additionalProperties" in dictionary with fixed keys ignored #16722

Open
5 of 6 tasks
czaefferer opened this issue Oct 4, 2023 · 0 comments
Open
5 of 6 tasks

Comments

@czaefferer
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am using an OpenAPI declaration to generate Dart-code with Dio as the client. The API allows some text to be translated, so it uses a string dictionary for those. As fixed keys, it declares "de-DE", "en-US" and "default" (since those are the ones usually used), but since more languages should be supported when needed there is also "additionalProperties" set. This is described here:

https://swagger.io/docs/specification/data-models/dictionaries/#fixed-keys

(In the documentation the fixed keys are used to declare them as required, the API I'm using does not. But even if it did set these keys as required, the behaviour below would not change.)

When I generate my client, the generated model class only contains three fields (the fixed keys), but no way to set/get more languages. If the fixed keys were to be removed from the declaration, a string-map would be used, that way allowing all languages to be set/get.

openapi-generator version

docker latest: openapi-generator-cli 7.1.0-SNAPSHOT commit : 7087b33
and docker latest-release: openapi-generator-cli 7.0.1 commit : 6745998

OpenAPI declaration file content or url

This is the condensed version containing the relevant part of a larger declaration: https://gist.github.com/czaefferer/a215fd8472cfaf14aa7a0416c30060f9

Generation Details / Steps to reproduce

I am using the docker based generator to generate a Dart client for the declaration above:

docker run --rm \
	-v ${PWD}/test-additional-properties.json:/configuration/swagger.json \
	-v /tmp/test-gen:/output \
	openapitools/openapi-generator-cli:latest generate \
	-i /configuration/swagger.json \
	-g dart-dio \
	-o /output \
	--additional-properties=serializationLibrary=json_serializable

Ignoring all annotations and boilerplate code, this is the resulting class for the dictionary:

class TestName {
  TestName({
     this.deDE,
     this.enUS,
     this.default_,
  });

  final String? deDE;
  final String? enUS;
  final String? default_;
}

-> I cannot retrieve or set more languages than those a fixed key exists for.

I would expect to have an additional Map<String, String> containing all or all additional strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant