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

Body is serialized as a list instead of an object #172

Open
isaac-merkos opened this issue Dec 17, 2024 · 2 comments
Open

Body is serialized as a list instead of an object #172

isaac-merkos opened this issue Dec 17, 2024 · 2 comments
Labels
bug Something isn't working waiting for response

Comments

@isaac-merkos
Copy link

Description of the bug

i have a simple login route, the body should be submitted like this

{
    "email":"[email protected]",
    "password":"secret"
}

But instead the payload is this

[
    "emali",
    "[email protected]",
    "password",
    "secret"
]

Here is my spec

"LoginParams": {
    "properties": {
        "email": {
            "type": "string"
        },
	"password": {
            "type": "string"
	}
    },
    "required": [
        "email",
        "password"
    ],
    "type": "object",
    "additionalProperties": false
},

And I am calling this endpoint like this

authApi.loginEmailPassword(loginParams: LoginParams((b) {
    b.email = email;
    b.password = password;
}))

Steps to reproduce

Create a body with the LoginParams type

Minimal openapi specification

"LoginParams": {
    "properties": {
        "email": {
            "type": "string"
        },
	"password": {
            "type": "string"
	}
    },
    "required": [
        "email",
        "password"
    ],
    "type": "object",
    "additionalProperties": false
},

Annotation used

@Openapi(
    additionalProperties: AdditionalProperties(
      useEnumExtension: true,
      pubName: 'api_client',
    ),
    inputSpec: RemoteSpec(path: 'http://localhost:3000/openapi.json'),
    generatorName: Generator.dio,
    skipIfSpecIsUnchanged: false,
    outputDirectory: 'api/api_client'
)

Here is my client

authApi = AuthApi(dio, serializers);

serializers is imported from package:api_client/src/serializers.dart

Expected behavior

I expected the body payload to be in the correct format

Logs

No response

Screenshots

No response

Platform

Windows

Library version

6.0.0

Flutter version

3.2

Flutter channel

stable

Additional context

No response

@isaac-merkos isaac-merkos added the bug Something isn't working label Dec 17, 2024
@gibahjoe
Copy link
Owner

Hello, please could you provide a spec that reproduces the issue?

A complete spec that is as the spec you provided cannot be run against the generator.

@isaac-merkos
Copy link
Author

Sorry I don't have the schema anymore, I made a lot of changes to the api structure and it works now

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

No branches or pull requests

2 participants