Enumeration needs to add description
caixingyue opened this issue · 10 comments
This is my current definition method:
#[Property(property: 'gender', description: "Gender (0:Secret; 1:Male; 2:Female)", type: 'string', enum: Gender::class, example: Gender::Secret)]
I want to get (0:Secret; 1:Male; 2:Female)
from the enum class, That is to say, you only need to write the following to achieve the above results.
#[Property(property: 'gender', description: "Gender", type: 'string', enum: Gender::class, example: Gender::Secret)]
This will reduce my maintenance costs.
I think this is a very specific use case that should not be the responsibility of the core library.
However, it should be reasonably simple to write a new processor that could perform this conversion. In that case, however, I'd suggest description: Gender:class
so the processor can check if a given description denotes a know enum.
I think this is a very specific use case that should not be the responsibility of the core library. However, it should be reasonably simple to write a new processor that could perform this conversion. In that case, however, I'd suggest
description: Gender:class
so the processor can check if a givendescription
function denotes a know enum.
Yes, you are right. This is indeed what the processor should handle. I have tried to use the processor to handle this problem, but the enumeration I got is an array, not an enumeration class. I want to obtain relevant enumeration information through the description
method of the enumeration class. I don't know if this is possible.
ps: Except for the implementation through x, I think I can directly use the key value of the existing enum
If you have some work in progress code that you could post I'd be happy to help - sounds like a good addition to the processor examples :)
If you have some work in progress code that you could post I'd be happy to help - sounds like a good addition to the processor examples :)
This allows you to pass enum data directly to the processor when calling it. For example, if I pass the enumeration class name, I should get the enumeration class name. If I need to get all the data of the enumeration, I can use enum_exists
to determine whether it is an enumeration class and then get the data myself.