All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
TODO: Describe changes.
- It is now possible to load multiple specs into a single router via
Router.AddSpec
method. (#46)
- Fixed a panic on empty basePath in spec (#45)
- Array type params are now properly parsed honoring collectionFormat.
That's a lot of changes in this upcoming release :)
- New
oas.Wrap()
option foroas.NewRouter()
applies a middleware that wraps the router. That means it executes before the actual routing, so you can modify its behaviour, e.g. introducing new routes (handling 404 errors) or methods (handling OPTIONS method for CORS). Seeoas.Wrap()
documentation for more information. Note that those middleware also applies to a spec served by router, when enabled viaoas.ServeSpec()
option. DefaultBaseRouter()
got exposed for informational purposes.DefaultExtractorFunc()
was added, so users don't need to import chi package if they use default router. Thus, you can justoas.Use(oas.PathParameterExtractor(oas.DefaultExtractorFunc))
-
Middleware order got adjusted. Now, when you pass middleware to
oas.NewRouter()
usingoas.Use()
option, they get applied exactly in the same order. Seeoas.Use()
option documentation and this test for an example. -
oas
package now introduces wrapper typesoas.Document
andoas.Operation
. All functions that previously exposed parameters from other libraries from go-openapi now use these types.For example,
oas.LoadFile()
now returns*oas.Document
instead of*loads.Document
. Thus,oas.NewRouter()
accepts*oas.Document
instead of*loads.Document
.The main purpose for this change is that most users only need those types to use within this library, and they had to import go-openapi libraries just to pass variables around. Also, you still can access underlying types from go-openapi if you need.
Functions that had their signatures changed:
oas.LoadFile()
oas.NewRouter()
oas.WithOperation()
oas.GetOperation()
oas.MustOperation()
-
Adjusted string representation of variables of type
oas.ValidationError
. -
All package middlewares that require
oas.Operation
to work now panic if operation is not found in the request context. Previously, if middleware cannot find operation in request context, it would just silently skip the validation. That behavior is undesirable because validation is important. So, the change is done to actually notify package user that he is doing something wrong.Affected middlewares:
oas.PathParameterExtractor()
oas.QueryValidator()
oas.BodyValidator()
oas.ResponseBodyValidator()
- Fixed a bug when
oas.LoadFile
was not returning expanded spec.
- New feature: It is now possible to pass additional options to middlewares. In particular, the first available option is to provide Content-Type selectors to validators.
- Breaking Change Router now accepts a document instead of a spec. This allows, among other things, to access original spec, which is used when serving router spec.
- Breaking Change
LoadSpec
function is replaced withLoadFile
, which works almost the same way, but provides more options, for example to set spec host when loading. - Breaking Change
DecodeQuery
now accepts request and extracts operation spec from it, so developer no longer need to extract operation params from request only to use them inDecodeQuery
. Old function moved toDecodeQueryParams
.
- Fixed a bug about type conversion for
default
values of query parameters.
- Fixed a bug that led to serving spec with duplicate parameters.
- New feature: add option
ServeSpec
for router to serve its OpenAPI spec under the base path. - New tool: oas-expand expands all
$ref
s in spec to improve startup time of the application. - OpenAPI parameter with
type: string
andformat: uuid
is now supported.
- Breaking Change
JsonError
renamed toJSONError
. - Replaced internally-used self-written response recorder with chi's
- The project now has more advanced CI checks.