Skip to content

schema response per content type #621

@eladchen

Description

@eladchen

💬 Question here

Would you consider updating the schema response config to also support a response per the request "accept" header?

const schema = {
   response: {
      // Augment the current mapping (status code -> response schema) to support
      // status code -> accept header -> response schema
      200: {
         "application/vnd.bla.v1+json": ...
         "*/*": ...
      }
   }
}

fastify.get("/apples/:id", { schema } , (request, reply) => {
  switch (request.header["accept"]) {
    case "application/json":
       reply.send(...);
       break;
   
    case "application/vnd.bla.v1+json":
       reply.send(...);
       break;
  }
});

This would also be beneficial when fastify-swagger dynamically generates an OAS v3 definition.

fastify/fastify-swagger#117

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions