Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples in OpenApiResponse #213

Closed
mzielinski opened this issue Jan 30, 2024 · 1 comment
Closed

Examples in OpenApiResponse #213

mzielinski opened this issue Jan 30, 2024 · 1 comment

Comments

@mzielinski
Copy link

mzielinski commented Jan 30, 2024

Describe the feature

It would be good to have possibility to define example response for each of OpenApiResponse

 responses = [
        OpenApiResponse(
            status = "200",
            description = "SUCCESS",
            content = [OpenApiContent(Response::class)]
        ),
        OpenApiResponse(
            status = "500",
            description = "UNEXPECTED_ERROR",
            content = [OpenApiContent(Response::class)]
        ),
        OpenApiResponse(
            status = "503",
            description = "SERVICE_UNAVAILABLE",
            content = [OpenApiContent(Response::class)]
        )
    ],

I have such content in OpenAPI specification:

image

It would be nice to have possibly to define examples and finally have such output

image

To achieve that, we need to inject example into content part

 "500": {
     "description": "UNEXPECTED_ERROR",
     "content": {
         "application/json": {
             "schema": {
                 "$ref": "#/components/schemas/Response"
            },
            "example": {
                "statusCode": "500",
                 "subStatusCode:": "ERROR-CODE-500-1",
                 "statusMessage": "Unexpected Error"
            }
        }
    }
},
@dzikoysk
Copy link
Member

Yes, I already had a conversation about this particular feature on our Discord server today, and it was reported an hour ago in #212 :) It should be implemented by the end of this week.

@dzikoysk dzikoysk moved this from 🆕 New to 📋 Backlog in Javalin OpenApi Jan 30, 2024
@mzielinski mzielinski changed the title Examples in OpenpiResponse Examples in OpenApiResponse Jan 31, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Javalin OpenApi Feb 3, 2024
@dzikoysk dzikoysk added this to the 6.0.1 milestone Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants