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 general info #44

Merged
merged 2 commits into from
Feb 13, 2019
Merged

Add support for general info #44

merged 2 commits into from
Feb 13, 2019

Conversation

ghostbuster91
Copy link
Contributor

@ghostbuster91 ghostbuster91 commented Feb 2, 2019

This refers to #11

I am not sure about this duplication of classes (Info, Contact, Licence) since their purpose is only to hold information relevant for openApi. So they could live in openApi module and be provided as we convert endpoint to openApi structures.

On the other hand there is e.g. a root server structure which may affects the behavior of endpoints, so it will have to have a representation in tapir module.

I wonder whether we should keep parts of openApi structers only in relevant modules or to have consistent api with duplicates.

An example:

  1. with duplicates
val endpoint: Endpoint = ....
val api = tapir.Api(info = ..., endpoints= ..., server = ...)  <- all those things live in tapir module
val openApi = api.toOpenAPI
val http4sRoute = endpoint.toHttp4s(api)
val endpoint: Endpoint = ....
val server = tapir.Server
val info = openapi.Info
val openApi = endpoint.toOpenapi(server, info)
val http4sRoute = endpoint.toHttp4s(server)

Update:
Since there can be multiple servers specified we always need to explicitly provide a particular instance.

@adamw
Copy link
Member

adamw commented Feb 3, 2019

I think I would avoid duplicates as long as possible - that is, once there's a really use-case for Api-like classes outside of documentation generation (be it openapi or not), let's leave them in the docs modules.

That might be also intersecting with softwaremill/sttp-apispec#4: to conveniently define the openapi metadata structures, you might need some builder methods/alternate constructors etc., which would directly yield e.g. OpenAPI, Info etc.

}

implicit class RichOpenAPIEndpoints(es: Iterable[Endpoint[_, _, _, _]]) {
def toOpenAPI(title: String, version: String)(implicit options: OpenAPIDocsOptions): OpenAPI =
EndpointToOpenAPIDocs.toOpenAPI(title, version, es, options)
def toOpenAPI(info: Info)(implicit options: OpenAPIDocsOptions): OpenAPI =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a może zostawić oba warianty: jeden z title: String, version: String i drugi z info: Info? Ten drugi by dawał pełną elastycznośc, pierwszy by zapewniał "szybką ścieżkę"?

@adamw adamw merged commit 5482f66 into master Feb 13, 2019
@ghostbuster91 ghostbuster91 deleted the general-info-support branch July 15, 2019 15:08
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 this pull request may close these issues.

2 participants