samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.85k stars 95 forks source link

@TypedQuery's openapi output is nested in the query parameter #723

Closed ryosukemori closed 10 months ago

ryosukemori commented 11 months ago

Thank you very much for a very nice package, we have been able to build validations very easily with Nestjs and have received a great experience.

It works correctly in most situations, but in @TypedQuery, when I output an OpenAPI schema, it becomes an object nested in parameters and I am unable to use fetch() with OpenAPI types in the front end.

Is there a workaround in Nestia to improve this?

@TypedRoute.Get()
  public async findMany(
    @TypedQuery() query: FollowFindManyQuery,
    @CurrentUser() user: User,
  ): Promise<UserPublicResponse[]> {
    console.log(query)
    return this.followsService.findMany(query, user)
  }
image
"get": {
        "tags": [],
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "schema": {
               // in query nest object
              "$ref": "#/components/schemas/FollowFindManyQuery"
            },
            "description": "",
            "required": true
          }
        ],
samchon commented 11 months ago

Configure INestiaConfig.swagger.decompose property to be true, then it would be decomposed.

image

ryosukemori commented 11 months ago

@samchon Thank you!

I had missed it. Now I can build comfortably.