-
Notifications
You must be signed in to change notification settings - Fork 374
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
Tags for Endpoint API #2716
Labels
Comments
This would be a nice feature to have. As a workaround until this gets implemented, I added the tags manually to the generated OpenAPI spec. It's a bit hacky, but it works: val openApiSpec: OpenAPI =
def addTagsToOperation(operation: OpenAPI.Operation, tags: Seq[String]): OpenAPI.Operation =
operation.copy(tags = operation.tags ++ tags)
def addTagsToPathItem(pathItem: OpenAPI.PathItem, tags: Seq[String]): OpenAPI.PathItem =
pathItem.copy(
get = pathItem.get.map(addTagsToOperation(_, tags)),
put = pathItem.put.map(addTagsToOperation(_, tags)),
post = pathItem.post.map(addTagsToOperation(_, tags)),
delete = pathItem.delete.map(addTagsToOperation(_, tags)),
options = pathItem.options.map(addTagsToOperation(_, tags)),
head = pathItem.head.map(addTagsToOperation(_, tags)),
patch = pathItem.patch.map(addTagsToOperation(_, tags)),
trace = pathItem.trace.map(addTagsToOperation(_, tags))
)
def addTagsToOpenApiSpec(openApiSpec: OpenAPI, tags: Seq[String]): OpenAPI =
openApiSpec.copy(paths = openApiSpec.paths.map {
case (path, pathItem) => (path, addTagsToPathItem(pathItem, tags))
})
val defaultEndpointSpec = addTagsToOpenApiSpec(OpenAPIGen.fromEndpoints(defaultEndpoints), Seq("default"))
val adminSpec = addTagsToOpenApiSpec(OpenAPIGen.fromEndpoints(adminEndpoints), Seq("admin"))
(defaultEndpointSpec ++ adminSpec)
.title("Example service")
.copy(tags = List(OpenAPI.Tag("default", None, None), OpenAPI.Tag("admin", None, None))) |
/bounty $150 |
💎 $150 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio-http! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Both smithy and OpenAPI offer tagging for endpoints.
The Endpoint API should have a concept of tagging endpoints. And they should be included in generated OpenAPI objects
The text was updated successfully, but these errors were encountered: