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

Required form fields for PUT method always false? #565

Closed
Jaap-van-Hengstum opened this issue Jan 16, 2015 · 9 comments
Closed

Required form fields for PUT method always false? #565

Jaap-van-Hengstum opened this issue Jan 16, 2015 · 9 comments

Comments

@Jaap-van-Hengstum
Copy link

Is there a reason why for the PUT request the required form fields are always false, while for the POST / PATCH methods they reflect what is specified in the form class?

If this has to do with the idempotence of the PUT method, my inclination was to do it the other way round (POST/PATCH does not require all the form fields while PUT does)...

PUT request:
put

POST / PATCH requests:
post

patch

@Jaap-van-Hengstum Jaap-van-Hengstum changed the title Required form fields with PUT request always false? Required form fields with PUT method always false? Jan 16, 2015
@Jaap-van-Hengstum Jaap-van-Hengstum changed the title Required form fields with PUT method always false? Required form fields for PUT method always false? Jan 16, 2015
@nakashu
Copy link

nakashu commented Mar 9, 2015

bump ..
Noticed this also. Can someone please explain the reasoning, or link to a resource explaining it.
If the main reason for it is possibility to do partial update with PUT, should then also PATCH have all fields optional ?

@willdurand
Copy link
Collaborator

Well, PUT should not be all set to false, and PATCH should get a diff, not single values.

@nakashu
Copy link

nakashu commented Mar 10, 2015

Sorry. am confused from the answer. Are saying that it is a bug then ?
That PUT documentation should respect definitions?

@michaelpopok
Copy link

Up the original question.

In this article @willdurand has stated:

Updating a resource in REST means replacing it actually, especially if you use the PUT HTTP verb.

So as I understand all fields for an entity should be required in case of PUT action (can be exceptions in some cases). Anyway I believe that this check should be removed in Extractor:

if ('PUT' === $annotation->getMethod()) {
    // All parameters are optional with PUT (update)
    array_walk($parameters, function ($val, $key) use (&$parameters) {
        $parameters[$key]['required'] = false;
    });
}

@judgedim
Copy link

judgedim commented Apr 6, 2015

@michaelpopok I suggest you provide PR :)

michaelpopok pushed a commit to michaelpopok/NelmioApiDocBundle that referenced this issue Apr 6, 2015
@hgiesenow
Copy link

I think someone mixed up PUT with PATCH.
For PATCH it makes sense, that there are no required field, as the resource must already exists and there is afaik no way to clear a filled field.

hgiesenow added a commit to kuborgh/NelmioApiDocBundle that referenced this issue Jun 24, 2015
@tristanlins
Copy link

Is there a chance to merge the fix kuborgh@72ab9b9 from @kuborgh-hgiesenow ?
I'm still confused of this issue :-D

@willdurand
Copy link
Collaborator

Can someone open a Pull Request for that?

@hgiesenow
Copy link

The codebase (especially tests) have changed too much since 2.10.0, so it's not mergable anymore. I had no time to look at it again.
@tristanlins feel free to open a new PR (based on mine if you wish to)

rodrigm added a commit to rodrigm/NelmioApiDocBundle that referenced this issue Jan 26, 2016
Change PUT by PATCH
rodrigm added a commit to rodrigm/NelmioApiDocBundle that referenced this issue Jan 26, 2016
@rodrigm rodrigm mentioned this issue Jan 26, 2016
rodrigm added a commit to rodrigm/NelmioApiDocBundle that referenced this issue Feb 24, 2016
Change PUT by PATCH

Refactor tests for nelmio#565
willdurand added a commit that referenced this issue Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants