jhthorsen / mojolicious-plugin-openapi

OpenAPI / Swagger plugin for Mojolicious
54 stars 44 forks source link

Support Gzipped Content #120

Closed srchulo closed 5 years ago

srchulo commented 5 years ago

This may or may not be an issue with Mojolicious::Plugin::API, so if I'm misunderstanding, feel free to close this.

I added support for gzip using the after_render hook as shown here:

https://metacpan.org/pod/Mojolicious::Guides::Rendering#Post-processing-dynamic-content

When I do this, it breaks any responses that use the openapi renderer. I get an error like this:

[{"message":"Missing property.","path":"\/errors"}]

What's interesting about this, is I thought after_renderwould be called after openapi had already validated the output and rendered the JSON. I actually validated this by placing my own openapi renderer as shown here:

https://metacpan.org/pod/Mojolicious::Plugin::OpenAPI#RENDERER

And printing out there and in my gzip hook, and the openapi renderer that returns the JSON does happen first. Maybe there's something else the OpenAPI plugin is doing that I'm not aware of? Validating after the JSON string has been generated?

srchulo commented 5 years ago

Also, what's interesting is that when the after_render hooks is called after I believe the openapi render has rendered the JSON, the format passed in $format to after_render is 'html'.

jhthorsen commented 5 years ago

Sorry, I hit the wrong button by mistake. (close/reopened)

I agree with you that it doesn't make any sense, so I need an example test/code to see what's really going on.

("Example test/code", means something small and manageable)

jhthorsen commented 5 years ago

Going to close this issue, unless a small example is provided.