Skip to content

Commit

Permalink
Merge pull request #1 from getkin/master
Browse files Browse the repository at this point in the history
merge from getkin/kin-openapi master to local master
  • Loading branch information
slessard authored Jun 7, 2022
2 parents dff5cc6 + 648d6b9 commit a3b0058
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ Licensed under the [MIT License](./LICENSE).
The project has received pull requests from many people. Thanks to everyone!

Here's some projects that depend on _kin-openapi_:
* [https://github.com/Tufin/oasdiff](https://github.com/Tufin/oasdiff) - "A diff tool for OpenAPI Specification 3"
* [github.com/Tufin/oasdiff](https://github.com/Tufin/oasdiff) - "A diff tool for OpenAPI Specification 3"
* [github.com/danielgtaylor/apisprout](https://github.com/danielgtaylor/apisprout) - "Lightweight, blazing fast, cross-platform OpenAPI 3 mock server with validation"
* [github.com/deepmap/oapi-codegen](https://github.com/deepmap/oapi-codegen) - Generate Go server boilerplate from an OpenAPIv3 spec document
* [github.com/deepmap/oapi-codegen](https://github.com/deepmap/oapi-codegen) - "Generate Go client and server boilerplate from OpenAPI 3 specifications"
* [github.com/dunglas/vulcain](https://github.com/dunglas/vulcain) - "Use HTTP/2 Server Push to create fast and idiomatic client-driven REST APIs"
* [github.com/danielgtaylor/restish](https://github.com/danielgtaylor/restish) - "...a CLI for interacting with REST-ish HTTP APIs with some nice features built-in"
* [github.com/goadesign/goa](https://github.com/goadesign/goa) - "Goa is a framework for building micro-services and APIs in Go using a unique design-first approach."
* [github.com/goadesign/goa](https://github.com/goadesign/goa) - "Design-based APIs and microservices in Go"
* [github.com/hashicorp/nomad-openapi](https://github.com/hashicorp/nomad-openapi) - "Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations."
* [gitlab.com/jamietanna/httptest-openapi](https://gitlab.com/jamietanna/httptest-openapi) ([*blog post*](https://www.jvt.me/posts/2022/05/22/go-openapi-contract-test/)) - "Go OpenAPI Contract Verification for use with `net/http`"
* (Feel free to add your project by [creating an issue](https://github.com/getkin/kin-openapi/issues/new) or a pull request)

## Alternatives
Expand Down
4 changes: 4 additions & 0 deletions openapi3filter/validation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
legacyrouter "github.com/getkin/kin-openapi/routers/legacy"
)

// AuthenticationFunc allows for custom security requirement validation.
// A non-nil error fails authentication according to https://spec.openapis.org/oas/v3.1.0#security-requirement-object
// See ValidateSecurityRequirements
type AuthenticationFunc func(context.Context, *AuthenticationInput) error

// NoopAuthenticationFunc is an AuthenticationFunc
func NoopAuthenticationFunc(context.Context, *AuthenticationInput) error { return nil }

var _ AuthenticationFunc = NoopAuthenticationFunc
Expand Down
41 changes: 40 additions & 1 deletion routers/gorillamux/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,22 @@ func TestServerPath(t *testing.T) {
_, err = NewRouter(&openapi3.T{Servers: openapi3.Servers{
server,
&openapi3.Server{URL: "http://example.com/"},
&openapi3.Server{URL: "http://example.com/path"}},
&openapi3.Server{URL: "http://example.com/path"},
newServerWithVariables(
"{scheme}://localhost",
map[string]string{
"scheme": "https",
}),
newServerWithVariables(
"{url}",
map[string]string{
"url": "http://example.com/path",
}),
newServerWithVariables(
"http://example.com:{port}/path",
map[string]string{
"port": "8088",
})},
})
require.NoError(t, err)
}
Expand Down Expand Up @@ -268,3 +283,27 @@ func TestRelativeURL(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "/hello", route.Path)
}

func newServerWithVariables(url string, variables map[string]string) *openapi3.Server {
var serverVariables = map[string]*openapi3.ServerVariable{}

for key, value := range variables {
serverVariables[key] = newServerVariable(value)
}

return &openapi3.Server{
ExtensionProps: openapi3.ExtensionProps{},
URL: url,
Description: "",
Variables: serverVariables,
}
}

func newServerVariable(defaultValue string) *openapi3.ServerVariable {
return &openapi3.ServerVariable{
ExtensionProps: openapi3.ExtensionProps{},
Enum: nil,
Default: defaultValue,
Description: "",
}
}

0 comments on commit a3b0058

Please sign in to comment.