api-platform / docs

API Platform documentation
https://api-platform.com/docs/
167 stars 1.08k forks source link

3.1 enum support tutorial page #1727

Open Nayte91 opened 1 year ago

Nayte91 commented 1 year ago

Hello, thank you for the work!

In the 3.1 release news, you said:

Finally after quite some time (this issue was opened in 2018!), we have support for Enums in OpenAPI, REST and GraphQL. Both Doctrine ORM and ODM have support for enums through enumType which is supported by API Platform 3.0. Alan added their support over OpenAPI and GraphQL.

I would like to know more about enums, is it related to this post https://les-tilleuls.coop/blog/exposez-vos-enums-avec-api-platform ?

I didn't found anything about how to expose PHP's enum in the actual APIP3.1 doc (I may be blind!), if there's not isn't a good idea to adapt/translate/implement the above blogpost in the doc? I may work on it (as I will implement it few times in a personal project), so I can totally do this, I just need to know of this is the right direction, and if it's needed.

Let me know, Best regards,

alanpoulain commented 1 year ago

Hello, No it's not related to the post. It works out of the box: if you use an enum in your resource, it will be used for the OpenAPI and GraphQL schema. I don't think a documentation is necessary for this case. If you want to expose your enum as a resource, then you can follow the blog post. maybe we can write a documentation about it in this case.

Nayte91 commented 1 year ago

No it's not related to the post. It works out of the box: if you use an enum in your resource, it will be used for the OpenAPI and GraphQL schema. I don't think a documentation is necessary for this case.

Ok, I don't understand what changed since 3.0 so ^^ and how it works, therefore I can't write any doc about this new feature :/

If you want to expose your enum as a resource, then you can follow the blog post. maybe we can write a documentation about it in this case.

Let's go for this, I'll propose a new page. PR will come!