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

Simpler syntax for defining responses' schema #80

Open
utybo opened this issue Mar 22, 2023 · 1 comment
Open

Simpler syntax for defining responses' schema #80

utybo opened this issue Mar 22, 2023 · 1 comment

Comments

@utybo
Copy link
Owner

utybo commented Mar 22, 2023

Currently:

get("/hello") {
    respond(Greeting("You"))
} describe {
    summary = "Greet someone"
    200 response {
        json { schema<Greeting>(Greeting("Hi!")) }
    }
}

I think it would be possible to implement the invoke operator on the various valid types to allow the following syntax instead:

200 response {
    json<Greeting>(Greeting("Hi!"))
    (json or xml)<Greeting>(Greeting("Hi!"))
}
@utybo utybo added this to the 0.0.5 milestone Mar 22, 2023
@utybo
Copy link
Owner Author

utybo commented Aug 13, 2023

This is not possible until Kotlin's context() feature lands, because otherwise this requires defining an inline extension function (because of reified generic types) in BodyDsl

@utybo utybo modified the milestones: 0.0.5, TBD Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant