fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
915 stars 201 forks source link

Header enum value is not getting generated on @fastify/swagger #700

Closed vishnutmohan closed 1 year ago

vishnutmohan commented 1 year ago

I am using the below versions

fastify version: 3.29.0 @fastify/swagger: 6.1.1

I have defined my schema for the headers like below.


const headers = {
  $id: "headers",
  type: "object",
  properties: {
    Authorization: { type: "string" },
    "x-country": {
      type: "string",
      transform: ["toUpperCase"],
      enum: ["IN", "US", "CH", "AR", "MX", "UY", "BR"]
    },
    "x-commerce": {
      type: "string",
      description: "Example values: 'FA', 'SO', 'TO' etc"
    }
  }
};

And added in one of my request header like

exports.createProductSizeSchema = {
  tags: ["Product Size"],
  summary: "This API is used to create  Product Sizes",
  description: "productSize should be Unique",
  headers: { $ref: "headers#" }
}

But while generating the definition, enum value is not coming up. PFB the screenshot

Screenshot 2022-12-05 at 8 39 57 PM

Could you please let me know what I am doing wrong here?