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

[REQ] Add a new property "baseDataType" for containers #7560

Closed
noordawod opened this issue Oct 1, 2020 · 2 comments
Closed

[REQ] Add a new property "baseDataType" for containers #7560

noordawod opened this issue Oct 1, 2020 · 2 comments

Comments

@noordawod
Copy link
Contributor

noordawod commented Oct 1, 2020

Is your feature request related to a problem? Please describe.

For arrays and maps, the dataType property currently holds the complete definition of the container, as in:

List<ModelType>
Map<ModelType>

There is a property for the container type (baseType), but there's no property for the type itself: ModelType

Describe the solution you'd like

Add a new property in the generator, specifically when dealing with containers, that holds the generic type of the list/map. I propose to call it baseDataType.

Additional context

This is needed for Dart, as an example, when generating code for the constructors.

class AClass {
  AClass({
    this.prop = const <AnotherClass>[],    // this line cannot be created today.
  });

  final List<AnotherClass> prop;
}
@kuhnroyal
Copy link
Contributor

From my experience this is usually the property complexType.

      "openApiType" : "array",
      "baseName" : "tags",
      "complexType" : "Tag",
      "getter" : "getTags",
      "setter" : "setTags",
      "dataType" : "List<Tag>",
      "datatypeWithEnum" : "List<Tag>",
      "name" : "tags",
      "defaultValue" : "const []",
      "defaultValueWithParam" : " = data.tags;",

@noordawod
Copy link
Contributor Author

I'll check it, thanks @kuhnroyal!

@wing328 wing328 closed this as completed Jan 22, 2021
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

3 participants