fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
941 stars 209 forks source link

Set params bsonType cause loading forever when call API #680

Closed conduongtong closed 2 years ago

conduongtong commented 2 years ago

Prerequisites

Fastify version

4.3.0

Plugin version

7.4.1

Node.js version

18.5.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10

Description

image I required _id on params which type bson (ObjectID in mongo).

When I call API, it's not validate and keep loading forever. image

If I change to type: string, it's work normal.

Sorry for my bad english.

Steps to Reproduce

Change params to bsonType: 'string'.

Expected Behavior

No response

mcollina commented 2 years ago

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

conduongtong commented 2 years ago

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

  1. set schema in route. image
  2. options have params with _id: { bsonType: 'string' } image
  3. Go to swagger and try out, it's loading forever with that API. image
Uzlopak commented 2 years ago

A screenshot is not an appropriate reproducible example. Provide a repository which we can clone and test.

climba03003 commented 2 years ago

bsonType is not a valid keyword for swagger and openapi. I would say that it is expected behavior.

In order to get it works, you probably need to pass transform function to change all those unsupported keyword to a valid keyword.