VaporToOpenAPI icon indicating copy to clipboard operation
VaporToOpenAPI copied to clipboard

Response Type only working if array

Open FNG-2002 opened this issue 2 years ago • 1 comments

Hello, I encountered following problem.

I have following DTO:

struct GetStudentDTO: Content {
    var id: UUID
    var courseOfStudy: String
    var email: String
}

And following route:

student.get("me", use: getMe)
            .openAPI(
                summary: "[Student] Get me object",
                description: "This route returns general information about the student.",
                response: .type(GetStudentDTO.self),
                auth: .bearer()
            )

But in Swagger I don't see a response type. grafik

But if the response type is an array it does work.

student.get("me", use: getMe)
            .openAPI(
                summary: "[Student] Get me object",
                description: "This route returns general information about the student.",
                response: .type([GetStudentDTO].self),
                auth: .bearer()
            )

grafik

Can you please help me with that? Thanks in advance

FNG-2002 avatar Dec 11 '23 16:12 FNG-2002

@FNG-2002 Hi! I'm unable to reproduce the bug, is your GetStudentDTO exactly the same as in the description?

dankinsoid avatar Dec 20 '23 13:12 dankinsoid