zircote / swagger-php

A php swagger annotation and parsing library
http://zircote.github.io/swagger-php/
Apache License 2.0
5.06k stars 931 forks source link

Duplicate tags will not be filtered out #1645

Open caixingyue opened 4 weeks ago

caixingyue commented 4 weeks ago

I have defined the same tag in different classes. It is recommended to keep only one tag to avoid duplication.

"tags": [ { "name": "Auth", "description": "认证" }, { "name": "Other", "description": "其它能力" }, { "name": "Auth", "description": "认证" }, { "name": "Auth", "description": "认证" } ]

DerManoMann commented 4 weeks ago

Is that using the latest version?

caixingyue commented 4 weeks ago

Is that using the latest version?

Yes, version 4.10.6

image
DerManoMann commented 4 weeks ago

Interesting. Could you post some example annotations to replicate?

caixingyue commented 4 weeks ago

Interesting. Could you post some example annotations to replicate?

Yes, This my config

$this->processorPipeline = new Pipeline([ new Processors\DocBlockDescriptions(), new Processors\MergeIntoOpenApi(), new Processors\MergeIntoComponents(), new Processors\ExpandClasses(), new Processors\ExpandInterfaces(), new Processors\ExpandTraits(), new Processors\ExpandEnums(), new Processors\AugmentSchemas(), new Processors\AugmentRequestBody(), new Processors\AugmentProperties(), new Processors\BuildPaths(), new Processors\AugmentParameters(), new Processors\AugmentRefs(), new Processors\MergeJsonContent(), new Processors\MergeXmlContent(), new Processors\OperationId(), new Processors\CleanUnmerged(), new Processors\PathFilter([], ['/^\/merchant\/.*/']), new Processors\CleanUnusedComponents(true), new Processors\AugmentTags(), ]);

DerManoMann commented 3 weeks ago

Sorry for not being clearer - with annotations I meant some of your annotations/attributes where you define those tags? Ideally a subset that can be used to replicate the bug.

caixingyue commented 3 weeks ago

Sorry for not being clearer - with annotations I meant some of your annotations/attributes where you define those tags? Ideally a subset that can be used to replicate the bug.

I will provide different controllers for different sections, and will also filter them, leaving only one in the end

[OA\Tag(name: 'Auth', description: '认证')]

class AdminAuthController extends Controller

[OA\Tag(name: 'Auth', description: '认证')]

class MerchantAuthController extends Controller

DerManoMann commented 2 weeks ago

I think there is still not enough to reproduce the issue, unless it is related to the non-english description (sorry I cannot recognize the language). I would need some complete files that, if processed together, would result in the error. I am asking not to be difficult, but because there are unit tests covering this particular issue (as it has come up before) and therefore if it is a swagger-php issue would be a very edge case.

Having said that there is another issue with how you are using the Tag annotation. An explanation can be found here: https://github.com/zircote/swagger-php/issues/1633#issuecomment-2251862566

caixingyue commented 2 weeks ago

I think there is still not enough to reproduce the issue, unless it is related to the non-english description (sorry I cannot recognize the language). I would need some complete files that, if processed together, would result in the error. I am asking not to be difficult, but because there are unit tests covering this particular issue (as it has come up before) and therefore if it is a swagger-php issue would be a very edge case.

Having said that there is another issue with how you are using the Tag annotation. An explanation can be found here: #1633 (comment)

I saw your explanation. In your explanation, you managed the tags uniformly. And I don't manage them uniformly. I define tags for different classes in different php files, so this problem occurs.

But I still think that the same tag may exist for different controller definitions. Because of multi-tenancy, the same functions may exist between different tenants.