Skip to content

@Body is not parsed to Request Body schemaΒ #106

@Robstaa

Description

@Robstaa

Hi!
I am using the @Body decorator from routing-controllers and it somehow doesn't parse to the Swagger Docs.
I read that it might have to do with using @Body and not Request Body, but routing-controllers does not seem to support any Request Body Decorator.

The response is parsed correctly though!

export type SignUpBody = {
    email: string;
    password: string;
    userType: UserType;
};

@JsonController('/auth/')
export class AuthenticationController {
    @OpenAPI({
        summary: 'User sign up for buyer and supplier owners',
        description: 'Input value of `userType` can be either `supplier` or `buyer`',
        requestBody: {
            required: true,
            content: {
                'application/json': {
                    example: {
                        email: '[email protected]',
                        password: '1234!hello@',
                        userType: 'admin',
                    },
                },
            },
        },
        responses: {
            401: {
                description:
                    'Invalid password. Password must be at least 8 characters long, have at least one uppercase letter, one lowercase letter, one number, and one special character.',
            },
            409: {
                description: 'User already exists',
            },
            422: {
                description: 'Invalid access type',
            },
            500: {
                description: 'Internal server error',
            },
        },
    })
    @HttpCode(201)
    @ResponseSchema(User)
    @Post('sign-up')
    async signUp(@Body() body: SignUpBody): Promise<User> {
        return signUp(body);
    }
}

Any ideas how I can also parse the Body to the schema in the Swagger docs?
Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions