Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openapi3filter.RegisterBodyDecoder() / openapi3filter.UnregisterBodyDecoder() based on singleton #339

Closed
wtask opened this issue Apr 8, 2021 · 2 comments · Fixed by #340

Comments

@wtask
Copy link

wtask commented Apr 8, 2021

The subject is ugly mostly for tests. If one test needs custom decoder, but another expects to use original one this case is sucks.

As a protection, you can offer a function to obtain a registered decoder so that it can be restored ...

@fenollp
Copy link
Collaborator

fenollp commented Apr 12, 2021

Could you show in code what you are suggesting please?

@wtask
Copy link
Author

wtask commented Apr 12, 2021

Something like

originalDecoder := openapi3filter.GetBodyDecoder({contentType})
openapi3filter.RegisterBodyDecoder({contentType}, {customDecoder})
...
openapi3filter.RegisterBodyDecoder({contentType}, originalDecoder)

Or offer default decoder registry, which will be used to fill in used decoders

openapi3filter.RegisterBodyDecoder({contentType}, openapi3filter.DefaultBodyDecoder({contentType}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants