Skip to content

Releases: eropple/fastify-openapi3

v1.0.2

05 Feb 01:40
4680d90

Choose a tag to compare

  • fixed a bug where the following construction didn't locate the inner item:
    export const A = schemaType(
      "A",
      Type.Object({
        pages: Type.Array(B),  // <-- nested schemaType here
      })
    );

v1.0.1

03 Feb 23:40
fbd6ce6

Choose a tag to compare

  • One bug fix: Type.Any()/Type.Unknown() weren't being allowed properly, though they are valid JSON Schema for OpenAPI 3.1. that's allowed now.

v1.0.0

17 Jan 19:09

Choose a tag to compare

Minor iterations overall since v0.12.0 with one breaking change to be aware of:

  • Autowired security schemes now run as preValidation hooks instead of onRequest. The reason for this is...
  • Autowired security schemes can now see the request body. I had a need for being able to compute an HMAC over a request body in a security scheme, and this seemed like the most effective path forward.

Thanks for using the library!

aside: this took an unpleasant amount of time because of NPM's new trusted-providers scheme, which has caused substantial disruption to a lot of people and unduly privileges GitHub's own product for a result that is at best of murky value. So good job for that, GitHub. I sure do want to give you money these days!

v1.0.0-rc1: tracking typebox 1.0

16 Nov 01:28

Choose a tag to compare

Pre-release

Typebox hit 1.0, and broke a lot of stuff! Hooray! No, seriously, it was a good thing; they fixed a lot of things that were really a huge pain. It just meant that the fiddling in its guts that this plugin does got really sad. Also there's a weird bug with Fastify stripping out ~kind so I had to work around that too.

All tests pass at present, but I have not used this in anger yet. As such, we're gonna put this as an RC until I have time to evaluate it in anger.

v0.12.0: optional logging for OAS validation errors

11 Nov 15:30

Choose a tag to compare

  • Does what it says on the tin. The options object now takes printSpecificationOnValidationFailure and only logs your spec when it's true, because otherwise you can smash buffers due to spec length.

v0.11.1

11 Nov 15:22

Choose a tag to compare

  • improved logging when the plugin detects an invalid OAS spec.

v0.11.0 - vendor extensions for operations

21 Jul 20:55

Choose a tag to compare

  • added vendorPrefixedFields to the oas object in your Fastify route, which (as per OAS spec) requires all keys to be prefixed with x-. For example:
        fastify.get("/vendor-test", {
          schema: {
            response: {
              200: PingResponse,
            },
          },
          oas: {
            operationId: "vendorTest",
            summary: "Test vendor extensions",
            vendorPrefixedFields: {
              "x-custom-field": "custom-value",
              "x-rate-limit": 100,
              "x-internal": true,
              "x-complex-object": {
                nested: "value",
                array: [1, 2, 3],
                bool: false,
              },
            },
          },
          handler: async (req, reply) => {
            return { pong: true };
          },
        });
  • (internal) refactored some tests a bit for easier readability.

v0.10.2 - nested schema bug fix

25 Jun 17:47

Choose a tag to compare

  • Fixed a bug in nested schemas caused by everyone's worst enemy: mutable state. (Hiss.) Thanks to @seanedwards for the test case.

v0.10.0 - autowired security improvements

17 Feb 01:40

Choose a tag to compare

  • accepts { type: "apiKey", in: "cookie" } security schemes for autowired security.
  • all autowired security schemes now support passNullIfNoneProvided, which will pass null to your handler function if no credential is found instead of just returning 401. This is backwards-compatible with the prior handler implementation.

v0.9.0 - better content type handling!

10 Feb 14:53

Choose a tag to compare

  • Improves behavior when using content types that aren't application/json. By which I mean...adds behavior. Setting a content type explicitly via oas.body.contentType actually works now.
    • This won't support multiple content types; still need to think about the best way to do that.
    • Example from the test suite:
    await fastify.register(
      async (fastify: FastifyInstance) => {
        fastify.post("/qwop", {
          schema: {
            body: QwopModel,
            response: {
              200: PingResponse,
            },
          },
          oas: {
            body: {
              contentType: "application/x-www-form-urlencoded",
            },
          },
          handler: async (req, reply) => {
            return { pong: true };
          },
        });
      },
      { prefix: "/api" }
    );
    await fastify.ready();
  • Similarly, response bodies can now be specified with oas.responses (and similarly it doesn't support multiple content types yet). Example from the test suite:
    await fastify.register(
      async (fastify: FastifyInstance) => {
        fastify.get("/ping", {
          schema: {
            response: {
              200: PingResponse,
            },
          },
          oas: {
            responses: {
              200: {
                description: "No response description specified.",
                contentType: "application/x-www-form-urlencoded",
              },
            },
          },
          handler: async (req, reply) => {
            reply.header("Content-Type", "application/x-www-form-urlencoded");
            return "pong=true";
          },
        });
      },
      { prefix: "/api" }
    );

You will still need @fastify/formbody or similar to actually parse the content.