Skip to content

Introduce Generator settings#1748

Closed
DerManoMann wants to merge 2 commits into
zircote:masterfrom
DerManoMann:generator-settings
Closed

Introduce Generator settings#1748
DerManoMann wants to merge 2 commits into
zircote:masterfrom
DerManoMann:generator-settings

Conversation

@DerManoMann

@DerManoMann DerManoMann commented Mar 27, 2025

Copy link
Copy Markdown
Collaborator

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]]);

@smallsung

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

@DerManoMann

Copy link
Copy Markdown
Collaborator Author

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

Copy link
Copy Markdown
Collaborator Author

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

@smallsung

Copy link
Copy Markdown
Contributor

This pr meets my needs perfectly.

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.
@DerManoMann

Copy link
Copy Markdown
Collaborator Author

Closing in favour of #1756

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

Successfully merging this pull request may close these issues.

Ignore other annotations

2 participants