swagger-php icon indicating copy to clipboard operation
swagger-php copied to clipboard

Introduce `Generator` settings

Open DerManoMann opened this issue 9 months ago • 5 comments

Generator settings are following the same pattern as processor config and are stored under the key 'generator'.

Generator::getSetting() provides a shortcut to access generator settings.

Fixes #1747 by allowing to set Generator::setConfig(['generator' => ['ignoreOtherAttributes' => true]]);

DerManoMann avatar Mar 27 '25 21:03 DerManoMann

This is what I need, I think it can be designed to be more flexible.

Like:

$attributeArgs = ['IgnoreAnnotationClass1','IgnoreAnnotationClass2'];

foreach ($reflector->getAttributes() as $attribute) {
    if (in_array($attribute::class, $attributeArgs, true)) {
    	continue;
    }
}

or

interface IgnoreAttributes{}

foreach ($reflector->getAttributes() as $attribute) {
    if ($attribute instanceof IgnoreAttributes) {
    	continue;
    }
}

or to be more precise

interface IgnoreAttributes{
	public function ignoreOAAttributes():bool;
}

foreach ($reflector->getAttributes() as $attribute) {
    if ($attribute instanceof IgnoreAttributes && $attribute->ignoreOAAttributes()) {
    	continue;
    }
}

I prefer the second or third one.

smallsung avatar Mar 28 '25 04:03 smallsung

If you agree and don't have extra time, I can pr.

smallsung avatar Mar 28 '25 04:03 smallsung

I think I am still not quite sure what the actual requirements are.

Excluding any attributes that are not OpenApi attributes should be all yours - unless you extend from AbstractAnnotation. But then I would expect that the library should process them...??

Could you please define what the actual criteria is to exclude attributes (without any new interface/logic, etc.)?

DerManoMann avatar Mar 28 '25 06:03 DerManoMann

Having second thoughts about the way the settings are done, but other than that I think this is good.

DerManoMann avatar Mar 31 '25 00:03 DerManoMann

This pr meets my needs perfectly.

smallsung avatar Mar 31 '25 15:03 smallsung

Closing in favour of #1756

DerManoMann avatar Apr 18 '25 00:04 DerManoMann