docs icon indicating copy to clipboard operation
docs copied to clipboard

3.1 enum support tutorial page

Open Nayte91 opened this issue 2 years ago • 2 comments

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,

Nayte91 avatar Feb 23 '23 18:02 Nayte91

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.

alanpoulain avatar Feb 24 '23 09:02 alanpoulain

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!

Nayte91 avatar Feb 24 '23 09:02 Nayte91