Repository navigation
Conversation
…chost Api classes based on operations' auth methods Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
Contributor
There was a problem hiding this comment.
1 issue found across 133 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/test/resources/3_1/csharp/issue_25575.yaml">
<violation number="1" location="modules/openapi-generator/src/test/resources/3_1/csharp/issue_25575.yaml:5">
P2: This fixture only declares one security scheme, so the regression test cannot catch a bug where an Api class gets the wrong scheme's TokenProvider. Add a second scheme (for example, a bearer or OAuth2 scheme) used by a different tag, and assert that each Api class gets only its own provider. A webhook operation with its own security would also cover the webhook path.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| info: | ||
| title: issue 25575 | ||
| version: "1" | ||
| security: |
Contributor
There was a problem hiding this comment.
P2: This fixture only declares one security scheme, so the regression test cannot catch a bug where an Api class gets the wrong scheme's TokenProvider. Add a second scheme (for example, a bearer or OAuth2 scheme) used by a different tag, and assert that each Api class gets only its own provider. A webhook operation with its own security would also cover the webhook path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/test/resources/3_1/csharp/issue_25575.yaml, line 5:
<comment>This fixture only declares one security scheme, so the regression test cannot catch a bug where an Api class gets the wrong scheme's TokenProvider. Add a second scheme (for example, a bearer or OAuth2 scheme) used by a different tag, and assert that each Api class gets only its own provider. A webhook operation with its own security would also cover the webhook path.</comment>
<file context>
@@ -0,0 +1,40 @@
+info:
+ title: issue 25575
+ version: "1"
+security:
+ - api_key: []
+paths:
</file context>
Member
|
Thanks for the PR cc @devhl-labs |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25575
With an
apiKeyscheme declared, every generichost Api class tookTokenProvider<ApiKeyToken>in its constructor even when none of its operations used that scheme, breaking DI resolution for the others. The class-level TokenProvider blocks now key off per-class flags computed from the operations' own auth methods (webhook Api classes included), instead of the global scheme presence. Support files (ClientUtils,RateLimitProvider) are untouched.All 51 generichost samples regenerated (129
Api/*.csfiles, removals only);dotnet buildon sdk:8.0 passes for the issue repro, a mixed-scheme client, and the petstore sample;*CSharpgenerator test suite 104/104 with a new regression test + fixture.Summary by cubic
Fixes #25575: generichost Api classes now only inject
TokenProviderdependencies for security schemes their operations actually use, instead of always requiring them when a scheme is declared anywhere.TokenProvider<ApiKeyToken>in its constructor whenever the spec declared anapiKeyscheme, even if none of its operations used it, breaking DI resolution for those classes.ClientUtils,RateLimitProvider) are untouched, and a regression test with a fixture was added.Written for commit d863e4b. Summary will update on new commits.