seriousme / fastify-openapi-glue

A plugin for the Fastify webserver to autogenerate a Fastify configuration based on a OpenApi(v2/v3) specification.
MIT License
202 stars 34 forks source link

Compression doesn't work #595

Closed vitaliypavlenko closed 2 weeks ago

vitaliypavlenko commented 1 month ago

If you have compression registered and enabled in fastily and this package used - compression doesn't work. This is how it is used: `await fastify.register( import('@fastify/compress'), { global: true }, ); const openapiGlue = await import('fastify-openapi-glue'); const glueOptions = { specification: mergedApiDefinition, operationResolver: this._operationResolver.bind(this), };

await fastify.register(openapiGlue, glueOptions);`
If compression headers are sent - result is missing body, but it is present without headers:
`curl -H 'Accept-Encoding:gzip, deflate, br' -X POST http://localhost:3000/`
seriousme commented 1 month ago

Hi,

thanks for asking!

fastify-openapi-glue is a plugin for fastify, and the only thing it does is create a config for fastify that: a) binds routes like '/v2/pet' to a handler b) configures security handling and parameter validation for these routes

If the @fastify/compress plugin does not work then the most likely cause has to be encapsulation

Can you please try if you can create a simple working example with compress and a simple plugin like:

async function plugin (fastify, opts) {
  fastify.get('/', async (req, reply) => {
    return { hello: 'world' }
  })
}

If that works then fastify-openapi-glue should work as well, if not then maybe the fastify team can help out.

Kind regards, Hans

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'