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

Collection with formdata malformed for API #881

Open
1 task done
KriKrus opened this issue Aug 14, 2024 · 2 comments
Open
1 task done

Collection with formdata malformed for API #881

KriKrus opened this issue Aug 14, 2024 · 2 comments
Labels
bug Something isn't working validated

Comments

@KriKrus
Copy link

KriKrus commented Aug 14, 2024

Scribe version

4.37.1

PHP version

8.3.9

Framework

Laravel

Framework version

11.20.0

Scribe config

title => "xxx API Dokumentation"
auth.enabled => true
auth.default => true
auth.name => "Authorization"
logo => "logo.svg"
examples.faker_seed => 1234
strategies.headers => added [
    'override',
    [
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
        'im-client-type' => 'app',
        'im-app-version' => '2024.08.14',
        'im-device-id' => 'id123',
    ],
]: removed [
    'override',
    [
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
    ],
]

What happened?

The Command generates the postman collection and I want to upload it to the postman api using the put api, but the request gets rejected because of a validation failure.

The problem is following json part in a formdata request:

{
    "key": "size",
    "value": 84,
    "type": "text",
    "description": ":Attribute muss mindestens 0 sein."
}

which is generated from following rules of a form request:


    public function rules(): array
    {
        return [
            'size' => ['required', 'numeric', 'min:0'],
        ];
    }

Postman rejects the file, because the form data is set to type "text", but the value is an integer. Can the generation of the collection respect the type? I think the change needs to be made in the PostmanCollectionWriter in getFormDataParams, if its not type file always cast the value to a string?

Docs

@KriKrus KriKrus added bug Something isn't working triage labels Aug 14, 2024
@shalvah
Copy link
Contributor

shalvah commented Aug 24, 2024

Good catch. Could you send in a PR to fix?

@KriKrus
Copy link
Author

KriKrus commented Sep 26, 2024

Hey,
sorry for the late response. I was on vacation and had a lot todos. Yes, i can try to send a PR in the following weeks.

@shalvah shalvah added validated and removed triage labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validated
Projects
None yet
Development

No branches or pull requests

2 participants