SkeLLLa/fastify-oas

how is it possible to add OPEN API 3.0.0 features (Callbacks, Examples) in Fastify schema?

Closed this issue · 5 comments

gblok commented

.. or extend Fastify schema?

Could you please be more verbose? Probably adding some examples of what do you want to achieve.

gblok commented

prop examples

  "paths": {
    "/pet": {
      "put": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Pet"
              },
              "examples": {
                "foo": {
                  "summary": "A foo example",
                  "value": {
                    "name": "bar"
                  }
                },
                "bar": {
                  "summary": "A bar example",
                  "value": {
                    "name": "baz"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

spec

gblok commented

callbacks features

 callbacks: {
                myEvent: {
                    '{$request.body#/Callback}': {
                        post: {
                            requestBody: {
                                required: true,
                                content: {
                                    'application/json': {
                                        schema: {
                                            type: 'object',
                                            properties: {
                                                message: {
                                                    type: 'string',
                                                    example: 'Some event happened'
                                                }
                                            },
                                            required: ['message']
                                        }
                                    }
                                }
                            },
                            responses: {
                                200: {
                                    description: 'Your server returns this code if it accepts the callback'
                                }
                            }
                        }
                    }
                }
            },

That's currently unsupported. However it should be easy to add couple of lines somewhere here:
https://github.com/SkeLLLa/fastify-oas/blob/master/lib/openapi/constructor.js#L170
And here as well for proper documentation and typescript support (with importing CallbackObject type from opeanpi-ts):
https://github.com/SkeLLLa/fastify-oas/blob/master/lib/index.d.ts#L61

So if you would like to send PR, that would be great. If not, I'll try to add this, but couldn't promise that it will be fast.

gblok commented

ok