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

Wrong generation when definigion is an array of objects #108

Closed
Vovanella95 opened this issue Dec 27, 2020 · 4 comments · Fixed by #231
Closed

Wrong generation when definigion is an array of objects #108

Vovanella95 opened this issue Dec 27, 2020 · 4 comments · Fixed by #231
Labels
bug Something isn't working

Comments

@Vovanella95
Copy link
Collaborator

Wrong generation when definigion is an array of objects

@PKIE
Copy link

PKIE commented Mar 14, 2021

Same issue here. Tried with 1.6.8
Sample openapi schema
openapi.txt
Array type definition is:

"ListCustomItem": {
  "type": "array",
  "items": {
    "$ref": "#/components/schemas/CustomItem"
  }
}

As a result the CustomItem is fine, but ListCustomItem generated code is empty:

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

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

  static const fromJsonFactory = _$ListCustomItemFromJson;
  static const toJsonFactory = _$ListCustomItemToJson;
  Map<String, dynamic> toJson() => _$ListCustomItemToJson(this);
}
ListCustomItem _$ListCustomItemFromJson(Map<String, dynamic> json) {
  return ListCustomItem();
}

Map<String, dynamic> _$ListCustomItemToJson(ListCustomItem instance) =>
    <String, dynamic>{};

@fryette
Copy link
Contributor

fryette commented Mar 15, 2021

@PKIE
Copy link

PKIE commented Mar 16, 2021

Thank you @fryette
Do you know if there is a way to override types for array type properties?

@PKIE
Copy link

PKIE commented Mar 16, 2021

OK, I managed to change the schema generator (probably it was buggy, and now instead creating new ListCustomItem definition it simply defines the response (or internal array) as array of type

So thanks for help, and sorry for bugging ;)

@fryette fryette added the bug Something isn't working label Aug 26, 2021
Vovanella95 pushed a commit that referenced this issue Aug 28, 2021
Vovanella95 added a commit that referenced this issue Aug 28, 2021
* Fix #108

* Stabilized andd release preparation

* Fixed analyzer issues

* Fix in remove from coverage

* Added some tests

* Some fixes

* Added some cases for test

* Added some cases to example

* Added some cases to tests

* Aded cases for test data

* Covered Requests generator to 100%

Co-authored-by: uladzimir_paliukhovich <>
Vovanella95 added a commit that referenced this issue Aug 28, 2021
* Fix #108

* Stabilized andd release preparation

* Fixed analyzer issues

* Fix in remove from coverage

* Added some tests

* Some fixes

* Added some cases for test

* Added some cases to example

* Added some cases to tests

* Aded cases for test data

* Covered Requests generator to 100%

* Fixed some things

* Added token

Co-authored-by: uladzimir_paliukhovich <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants