![]() apiKey ( header ]( "token-new" ), mapDecode ) val alternativeOptionalAuthEndpoint = alternativeAuthEndpoint. apiKey ( header ]( "token-old" ), and ( auth. securityIn ( // auth.apiKey(.).and(auth.apiKey(.)) will map the request headers to a tuple (Option, Option) auth. _ val alternativeAuthEndpoint = endpoint. Is added (which doesn’t map to any values in the request, but only serves as a marker). If authentication should be optional, an empty security requirement will be added if an emptyAuth input However, this will not include the empty requirement, making authentication Security requirements will be created for them. If there are multiple optional authentication methods, they will be treated as alternatives, and separate alternative Hence, two security requirements will be created: an empty one, and one corresponding to the given authentication input. realm ( "realm" )))Ī single optional authentication method can be described by mapping to optional types, e.g. ![]() apiKey ( header ( "signature" ), WWWAuthenticateChallenge ( "ApiKey" ). apiKey ( header ( "token" ), securityIn ( auth. If you’d like to disable this feature, just provide a function that always returns None: You can override this option to customize the mapping of endpoint’s inputs to a default error response. Tapir will try to guess if decoding of inputs may fail, and add a 400 response if necessary. Operation id is auto-generated by concatenating (using camel-case) the request method and path.ĭefaultDecodeFailureOutput: if an endpoint does not define a Bad Request response in errorOut, By default, the name of endpoint is used as the operation id, and if this is not available, the OperationIdGenerator: each endpoint corresponds to an operation in the OpenAPI format and should have a unique Options can be customised by providing an instance of OpenAPIDocsOptions to the interpreter: toRoute ( SwaggerUI ( docsAsYaml )) Options toYaml // add to your akka routes val swaggerUIRoute = AkkaHttpServerInterpreter (). toOpenAPI ( myEndpoints, "My App", "1.0" ). global val myEndpoints : Seq = ? val docsAsYaml : String = OpenAPIDocsInterpreter (). Yaml format, will expose it using the given context path. The modules tapir-swagger-ui and tapir-redoc contain server endpoint definitions, which given the documentation in Them in a single step (see above), or you can do that separately. You can either both interpret endpoints to OpenAPI’s yaml and expose toYaml3_1 ) // OpenApi 3.1.0 YAML string would be printed to the console Exposing generated OpenAPI documentation Įxposing the OpenAPI can be done using Swagger UI or openapi ( "3.1.0" ) // "3.1.0" version explicitly specified // "3.1.0" version explicitly specified println ( docs. toOpenAPI ( booksListing, "My Bookshop", "1.0" ). in ( path ( "bookId" )) val docs : OpenAPI = OpenAPIDocsInterpreter (). OpenAPIDocsInterpreter case class Book ( id : Option, title : Option ) val booksListing = endpoint. ![]() _ // for `toYaml3_1` extension method // for `toYaml3_1` extension method import sttp. Similarly as above, you’ll need the following dependency: The swagger server endpoints can be secured using ServerLogic.prependSecurity, see server logic ![]() Finally, the generated model can be customised. Moreover, model generation can be configured - see below for more details on OpenAPIDocsOptions and the method To false, and specify the contextPath one. Within a context, and you don’t want Swagger to use relative paths, you’ll need to set the useRelativePaths options The path, as well as other options can beĬhanged when creating the SwaggerInterpreter and invoking fromEndpoints. toRoute ( swaggerEndpoints )īy default, the documentation will be available under the /docs path. fromEndpoints ( myEndpoints, "My App", "1.0" ) // add to your akka routes val swaggerRoute = AkkaHttpServerInterpreter (). global val myEndpoints : List = ? // first interpret as swagger ui endpoints, backend by the appropriate yaml val swaggerEndpoints = SwaggerInterpreter ().
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |