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

Type generation #224

Closed
XanderD99 opened this issue Apr 16, 2024 · 1 comment
Closed

Type generation #224

XanderD99 opened this issue Apr 16, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@XanderD99
Copy link

Steps to reproduce

create openapi spec with a path like

  /nearby:
    get:
      summary: Get nearby places
      tags:
        - Generic
        - Locations
      responses:
        '200':
          description: Return everything nearby
          content:
            application/json:
              schema:
                type: object
                properties:
                  locations:
                    type: array
                    items:
                      $ref: '#/components/schemas/Location'

run swagger parsert

Expected results

typed reponse schema for the response with properties

@Freezed()
class GetNearbyResponse with _$GetNearbyResponse {
  const factory GetNearbyResponse({
    required List<Locations> locations,
  }) = _GetNearbyResponse;
  
  factory GetNearbyResponse.fromJson(Map<String, Object?> json) => _$GetNearbyResponseFromJson(json);
}

Actual results

response class with no child parameteres

@Freezed()
class GetNearbyResponse with _$GetNearbyResponse {
  const factory GetNearbyResponse() = _GetNearbyResponse;
  
  factory GetNearbyResponse.fromJson(Map<String, Object?> json) => _$GetNearbyResponseFromJson(json);
}

Your OpenApi snippet

/nearby:
get:
summary: Get nearby places
tags:
- Generic
- Locations
responses:
'200':
description: Return everything nearby
content:
application/json:
schema:
type: object
properties:
locations:
type: array
items:
$ref: '#/components/schemas/Location'

Code sample

No response

Logs

No response

Dart version and used packages versions

Dart version
Dart SDK version: 3.3.3 (stable) (Tue Mar 26 14:21:33 2024 +0000) on "macos_arm64"```

</details><details><summary>Packages version</summary>

```console
^1.17.2
@StarProxima StarProxima self-assigned this May 9, 2024
@StarProxima StarProxima mentioned this issue May 9, 2024
@Carapacik Carapacik added the bug Something isn't working label May 9, 2024
@StarProxima
Copy link
Collaborator

@XanderD99 Hi, this should be fixed in the latest version, can you test it with your examples?

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

No branches or pull requests

3 participants