OAS server path as base path for matchers #45
Merged
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.
What
OAS server path as base path for matchers
When OpenAPI doc specifies base path in the
servers
top level object, all the operations are prefixed with the base path of the server object. For example:For this example, all the paths will be prefixed with
/api/v1
base path. The second server object is omitted.Verification Steps
httproute-kuadrant-extensions
git clone https://github.com/Kuadrant/kuadrantctl.git cd kuadrantctl git checkout kuadrant-extensions-server-path
bin/kuadrantctl
pathGET /cat
GET /api/v1/cat
POST /cat
POST /api/v1/cat
GET /dog
GET /api/v1/dog
POST /dog
POST /api/v1/dog
GET /mouse
GET /api/v1/mouse
bin/kuadrantctl generate gatewayapi httproute --oas petstore-openapi.yaml | kubectl apply -n petstore -f -
bin/kuadrantctl generate kuadrant ratelimitpolicy --oas petstore-openapi.yaml | kubectl apply -n petstore -f -
GET /api/v1/cat
-> It should return 200 Ok and be rate limited (1 req / 10 seconds)curl --resolve example.com:9080:127.0.0.1 -v "http://example.com:9080/api/v1/cat"
POST /api/v1/cat
-> Not added to the HTTPRoute. It should return 404 Not Foundcurl --resolve example.com:9080:127.0.0.1 -v -X POST "http://example.com:9080/api/v1/cat"
GET /api/v1/dog
-> It should return 200 Ok and be rate limited (3 req / 10 seconds)curl --resolve example.com:9080:127.0.0.1 -v "http://example.com:9080/api/v1/dog"
POST /api/v1/dog
-> It should return 200 Ok and NOT rate limitedcurl --resolve example.com:9080:127.0.0.1 -v -X POST "http://example.com:9080/api/v1/dog"
GET /api/v1/mouse
-> Not added to the HTTPRoute. It should return 404 Not Foundcurl --resolve example.com:9080:127.0.0.1 -v -X POST "http://example.com:9080/api/v1/mouse"