fastify / fastify-response-validation

A simple plugin that enables response validation for Fastify.
MIT License
51 stars 14 forks source link

Refactor, 100% TestCoverage, add ajv.plugins Option #75

Closed Uzlopak closed 2 years ago

Uzlopak commented 2 years ago

Resolves #42

I dont know how to add typings for the onRoute option.

Any suggestions?

Checklist

Uzlopak commented 2 years ago

@mcollina

Can you please assign somebody who knows how to Implement the on Route typings?

Uzlopak commented 2 years ago

@climba03003 gave me some hints. Will adapt them when i am back at a Computer.

Uzlopak commented 2 years ago

Fixed.

I actually would have preferred to have the same syntax as fastify does. Which would have been

type Options = {
   ajv: {
      customOptions: AjvOptions;
      plugins: (Function | [Function, unknown])[]
   }
}

But this should be fine also...

Uzlopak commented 2 years ago

If you are willing to make a major version release then i would like to put the ajvOptions into the customOptions key, to make it 100% identical to the request validation.

climba03003 commented 2 years ago

If you are willing to make a major version release then i would like to put the ajvOptions into the customOptions key, to make it 100% identical to the request validation.

We should land the refactor first. Then go on for the options consistency in fastify and plugin. I love to see the ajv options is consistence across fastify ecosystem.

Uzlopak commented 2 years ago

Should we integrate this into fastify core on the long run?

Eomm commented 2 years ago

Should we integrate this into fastify core on the long run?

No, I don't think so. I must say that validating the response is fine only in very rare cases in my opinion and should not be the default