softwaremill / softwaremill/tapir

[BUG] Security path inputs always goes before regular input segments

Open
#3,771 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.5k
Forks
468
Avg merge
5h 37m
Merged PRs (30d)
34

Description

Tapir version: 1.10.7

Scala version: 2.13.14

Security path segments always goes as first in the path. The sequence is not preserved.

What is the problem?

I need to declare endpoint where the security segment is not the first one.
The issue is not in OpenApi. Routes created from declarations also move security input as first segments.

Maybe you can provide code to reproduce the problem?

package com.softwaremill

import org.apache.pekko.actor.ActorSystem
import sttp.apispec.openapi.OpenAPI
import sttp.apispec.openapi.circe.yaml.RichOpenAPI
import sttp.tapir.docs.openapi.OpenAPIDocsInterpreter
import sttp.tapir.endpoint

object HelloWorldPekkoServer extends App {
  implicit val actorSystem: ActorSystem = ActorSystem()

  // should be /regular1/security1/regular2/security2
  // it is     /security1/security2/regular1/regular2:
  val helloWorld =
    endpoint.get
      .in("regular1")
      .securityIn("security1")
      .in("regular2")
      .securityIn("security2")


  val docs: OpenAPI = OpenAPIDocsInterpreter().toOpenAPI(helloWorld, "My Bookshop", "1.0")
  println(docs.toYaml)
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied Scala reproduction using endpoint.in and securityIn, then trace how the endpoint declaration is converted into routes and OpenAPI paths. Compare the generated path with the declared order; done means regular and security segments retain their original sequence in both outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, scala
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.