OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.77k stars 6.57k forks source link

[BUG][scala-sttp] error generating client with basic authentication #8395

Closed aneksamun closed 3 years ago

aneksamun commented 3 years ago

Bug Report Checklist

Description

I would like to generate a client which is required to use a basic authentication to connect to the service. Unfortunately I do get an error

value withCredentials is not a member of sttp.client.SpecifyAuthScheme[sttp.client.Identity,Either[String,String],Nothing]

Checking sttp client source code I can see that real function name should be basic. https://github.com/softwaremill/sttp/blob/61dc6aecc93c70891ba7c74bc100ed5e65a94777/core/src/main/scala/sttp/client3/RequestT.scala#L396

openapi-generator version

Occurs in 5.0.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Test API
  version: '1.0'
servers:
  - url: /api
paths:
  /ping:
    get:
      description: ping
      operationId: ping
      responses:
        '200':
          description: ping pong
          content:
            application/json:
              schema:
                type: string
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
security:
  - basicAuth: []
Generation Details
openapi-generator-cli generate \
  -i openapi.yaml \
  -g scala-sttp \
  --additional-properties sttpClientVersion=2.2.0,mainPackage=test.api \
  -o test-api
Steps to reproduce

Bug is easy reproducible using basic authentication as authentication method

Suggest a fix

Use correct function name in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/scala-sttp/api.mustache#L28

auto-labeler[bot] commented 3 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.