dankinsoid / VaporToOpenAPI

OpenAPI specification generator for Vapor based Swift projects.
MIT License
98 stars 8 forks source link

Some routes have disappeared after upgrading from 0.27 #1

Closed m-barthelemy closed 1 year ago

m-barthelemy commented 1 year ago

Saw that a few new releases were recently made, so I updated my app from 0.27. I'm glad errorResponses was added!

However after updating, many of my routes have disappeared from the generated OpenAPI. Examples:

    let groups = authenticated.grouped("groups")

    // ❌ Does not appear in openAPI
    groups.get(use: groupController.list)
        .openAPI(
            summary: "List \(Group.self)s",
            description: "List all the \(Group.self)s of the current \(Account.self)",
            response: [GroupDTO].self
        )

    // ✅ Properly appears in openAPI
    groups.get("blublublu", use: groupController.list)
        .openAPI(
            summary: "List \(Group.self)s",
            description: "List all the \(Group.self)s of the current \(Account.self)",
            response: [GroupDTO].self
        )

    // ❌ Does not appear in openAPI
    groups.get(":id", use: groupController.get)
        .openAPI(
            summary: "Get a \(Group.self) details",
            description: "Get details for a specific \(Group.self)s in the current \(Account.self)",
            response: GroupDTO.self,
            errorResponses: [
                404: NuwErrorMiddleware.ErrorResponse.init(error: true, reason: "Not found")
            ]
        )

    // ✅ Properly appears in openAPI
    groups.post(use: groupController.create)
        .openAPI(
            summary: "Create a \(Group.self)",
            description: "Create a new users \(Group.self) in the current \(Account.self)",
            body: CreateGroup.self,
            response: GroupDTO.self,
            errorResponses: [
                422: NuwErrorMiddleware.ErrorResponse.init(error: true, reason: "Error details"),
                409: NuwErrorMiddleware.ErrorResponse.init(error: true, reason: "Already exists")
            ]
        )

    // ❌ Does not appear in openAPI
    groups.put(":id", use: groupController.update)
        .openAPI(
            summary: "Update a \(Group.self)",
            description: "Update a \(Group.self) in the current \(Account.self)",
            body: CreateGroup.self,
            response: GroupDTO.self
            //responses: []
        )
dankinsoid commented 1 year ago

@m-barthelemy Hello, thank you for your response Could you let me know which version you use now?

dankinsoid commented 1 year ago

@m-barthelemy Fixed in 1.21.0

m-barthelemy commented 1 year ago

Wow that was fast. Confirmed, issue fixed 👍