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

Add support for server variables #3

Open
ghostbuster91 opened this issue Feb 2, 2019 · 2 comments
Open

Add support for server variables #3

ghostbuster91 opened this issue Feb 2, 2019 · 2 comments

Comments

@ghostbuster91
Copy link
Collaborator

ghostbuster91 commented Feb 2, 2019

This is a part of softwaremill/tapir#11

I decided to extract it since it is a big feature.

@ghostbuster91
Copy link
Collaborator Author

ghostbuster91 commented Feb 4, 2019

So I was thinking about possible dsl for server variables and we cannot use endpoint dsl here because of two reasons:

  • variables can be anywhere e.g. schema could be a variable.
  • variables must have a default value and optionally possible values

I came up with sth like this:

val v1 = Variable("v1", defaultValue=123).values(123, 456)
val server = Server(v"https://api.${v1}.io")

where v"" is a custom interpolator which does sth like that:

    import tapir.docs.openapi.StringInterpolation._
    val serverVariable = Variable("v1", defaultValue = 5)
    val result = v"kasper/$a"
    result shouldBe List(Constant("kasper/"), serverVariable) 

@adamw
Copy link
Member

adamw commented Feb 7, 2019

To be honest, I don't think it's a frequently used swagger feature (at least in my impression, I might be wrong of course). So I think it would be more than enough to just allow adding server variables to a model generated by tapir (but here just using case classes copy + possible quicklens might be enough).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants