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] Array in spec is not being generated as expected #313

Closed
alextarrago opened this issue Jan 14, 2022 · 4 comments · Fixed by #318
Closed

[BUG] Array in spec is not being generated as expected #313

alextarrago opened this issue Jan 14, 2022 · 4 comments · Fixed by #318
Assignees
Labels
bug Something isn't working Triage needed

Comments

@alextarrago
Copy link

Take a look on this spec.

"Services": {
  "type": "array",
  "items": {
    "$ref": "#/components/schemas/Service"
  }
},
"ServicesPage": {
  "allOf": [
    {
      "$ref": "#/components/schemas/Page"
    },
    {
      "type": "object",
      "properties": {
        "services": {
          "$ref": "#/components/schemas/Services"
        }
      }
    }
  ]
}, ...

It generates the following Dart classes (shortened for displaying purposes)

@JsonSerializable(explicitToJson: true)
class Services {
  Services();

  factory Services.fromJson(Map<String, dynamic> json) =>
      _$ServicesFromJson(json);

  static const fromJsonFactory = _$ServicesFromJson;
  static const toJsonFactory = _$ServicesToJson;
  Map<String, dynamic> toJson() => _$ServicesToJson(this);
}


@JsonSerializable(explicitToJson: true)
class ServicesPage {
  ServicesPage({
    this.services,
  });

  factory ServicesPage.fromJson(Map<String, dynamic> json) =>
      _$ServicesPageFromJson(json);

  @JsonKey(name: 'services', includeIfNull: false)
  final Services? services;
  static const fromJsonFactory = _$ServicesPageFromJson;
  static const toJsonFactory = _$ServicesPageToJson;
  Map<String, dynamic> toJson() => _$ServicesPageToJson(this);
}

No array is created for the Services object.

@alextarrago
Copy link
Author

Any news on this? @fryette

@Vovanella95
Copy link
Collaborator

Hi @alextarrago I did not checked this issue yet. Will try to do this this week

@Vovanella95
Copy link
Collaborator

Hi @alextarrago please check latest version 2.3.9

@alextarrago
Copy link
Author

Amazing @Vovanella95 . Thanks for the fast fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Triage needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants