Repository navigation
fix(openapi): skip OPTIONS operations when generating tools - #340
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe converter now skips OPTIONS operations case-insensitively, preventing an unwanted CORS tool when kin-openapi reports uppercase methods; the regression test requires exactly one generated tool and confirms the existing GET behavior. Flow diagram for case-insensitive OPTIONS tool filteringflowchart LR
Spec[OpenAPI specification] --> Converter[Converter.Convert]
Converter --> Method[Path operation method]
Method --> Check["strings.EqualFold(method, options)"]
Check -->|true| Skip[Skip CORS OPTIONS operation]
Check -->|false| Tool[Generate MCP tool]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
The OpenAPI converter intends to skip CORS OPTIONS operations, but kin-openapi returns uppercase HTTP methods. Comparing with lowercase
optionscreates an extra OPTIONS tool. Compare case-insensitively and strengthen the existing skip-options test to require exactly one tool.Validation:
go test ./pkg/openapi -count=1passes.go build ./cmd/...passes on Windows with Go 1.26.3.The test scope corresponds to
make test TEST_PACKAGES=./pkg/openapi; the full service suite was not run because this task permits offline synthetic fixtures only. No live MCP servers, model APIs, or backend services were started.Summary by Sourcery
Prevent OpenAPI conversion from generating tools for CORS OPTIONS operations.
Bug Fixes:
Tests: