0

In my project my intention is to configure fastify-swagger with OpenAPI version 3.0.0 with the following configuration:

I am using fastify-oas as fastify plugin such that my existing configuration does not need to alter.

const swaggerConfig = {
    swagger: {
      info: {
        title: `${constants.SERVICE_NAME.toUpperCase()} swagger`,
        description: `NetApp ${constants.SERVICE_NAME.toUpperCase()} service API.`,
        version: '1.0.0'
      },
      externalDocs: {
        url: 'https://swagger.io',
        description: 'Find more info here'
      },
      schemes: [`${schema}`],
      consumes: ['application/json'],
      produces: ['application/json'],
      tags: [
        { name: 'persistence', description: 'foo' },
        { name: 'index', description: 'bar'}
      ],
      securityDefinitions: {
        Authorization_Token: {
            type: 'apiKey',
            name: 'Authorization',
            in: 'header'
        }
      }
    },
    exposeRoute: true,
    routePrefix: `${constants.EXTERNAL_PATH}/api-docs`
};

fastify.register(require('fastify-oas'), swaggerConfig );

Actually I was trying to following the following link here (https://github.com/fastify/fastify-swagger/blob/master/examples/dynamic-openapi.js).

However somehow I am not able to succeed, always it shows the error that it's not able to load the swagger. Not seeing any error in the console. The error is like below screen shot:

enter image description here

Any clue how can I debug would be helpful how can I proceed with debugging this.

One interesting point is: as I am removing arbitrarily some portion of the schema just to see if I can pin point by trial and error, it's start working!

So if there a way to bit systematically debug it, would be great.

Thanks, Pradip

Pradip
  • 509
  • 1
  • 5
  • 22
  • The error I am seeing is: Fetch Error: Internal Server Error https://localhost/..... I have a relatively complex schema. As I am arbitrarily reducing some portions of the schema, it's start working! I am not getting a way how to systematically debug the issue. Any such pointer would be appreciated. – Pradip Aug 16 '21 at 16:09
  • You linked the `fastify-swagger` source code, but you are using the `fastify-oas` plugin. You should use one – Manuel Spigolon Aug 17 '21 at 08:46
  • I am sorry. My link was wrong. I am using fastify-oas only. – Pradip Aug 17 '21 at 14:24

0 Answers0