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

[BUG] Hidden body schema appears in OpenAPI specs #3617

Open
kciesielski opened this issue Mar 16, 2024 · 0 comments
Open

[BUG] Hidden body schema appears in OpenAPI specs #3617

kciesielski opened this issue Mar 16, 2024 · 0 comments
Labels
bug Something isn't working openapi

Comments

@kciesielski
Copy link
Member

As reported in https://softwaremill.community/t/hiding-input-body-in-openapi-generation/380

I have custom security authenticating, which require many fields from (original) request. The problem I’m now facing is that security part is affecting OpenAPI schema. I’m using Tapir 1.9.11.
Input for security looks like this:

  val securityIn: EndpointInput[TapirHmacRequestParts] = authorizationHeaders
    .and(extractFromRequest[(String, Map[String, String], String, String)] { request =>
      (
        request.method.method,
        request.headers.map(h => h.name -> h.value).toMap,
        request.underlying.asInstanceOf[RequestContext].request.uri.path.toString(),
        request.underlying.asInstanceOf[RequestContext].request.uri.rawQueryString.getOrElse(""),
      )
    })
    .and(byteArrayBody.schema(_.hidden(true)))
    .mapTo[TapirHmacRequestParts]

In endpoints it’s used like this

    .in(jsonBody[SearchApiQuery])
    .securityIn(TapirAuthorization.securityIn)

Adding this to endpoint, results in “application/octet-stream” instead of describing case classes SearchApiQuery.

      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary

It seems like byteArrayBody.schema(_.hidden(true)) is not working as I would expect.

@kciesielski kciesielski added bug Something isn't working openapi labels Mar 16, 2024
@kciesielski kciesielski changed the title [BUG[ Hidden body schema appears in OpenAPI specs [BUG] Hidden body schema appears in OpenAPI specs Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi
Projects
None yet
Development

No branches or pull requests

1 participant