Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #9345
Closed
Open
Issue created Apr 26, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [scala-sttp] Compilation fails with non-camelCase URI parameters

Created by: softdevca

The scala-sttp generator fails to compile when URI parameters are not camelCase. This is because method parameters in the API classes are converted to camelCase but the parameter names in the URI string are not converted.

For example, in the body below the compiler cannot find the address_id variable in the URI string because the parameter has been named addressId.

  def getAddress(addressId: String): Request[Either[ResponseError[Exception], AddressResponse], Nothing] =
    basicRequest
      .method(Method.GET, uri"$baseUrl/addresses/${address_id}")
      .contentType("application/json")
      .response(asJson[AddressResponse])

This is not an issue with the scala-akka generator because it's URI parameters are added by a method parameter.

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

master, not a regression

Steps to reproduce

The below test should verify the correct behavior.

package org.openapitools.codegen.scala;

import org.openapitools.codegen.languages.ScalaSttpClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;

public class SttpCodegenTest {

    private final ScalaSttpClientCodegen codegen = new ScalaSttpClientCodegen();

    @Test
    public void encodePath() {
        Assert.assertEquals(codegen.encodePath("{user_name}"), "${userName}");
        Assert.assertEquals(codegen.encodePath("{userName}"), "${userName");
        Assert.assertEquals(codegen.encodePath("{UserName}"), "${userName}");
        Assert.assertEquals(codegen.encodePath("user_name"), "user_name");
        Assert.assertEquals(codegen.encodePath("before/{UserName}/after"), "before/${userName}/after");
    }

}
Suggest a fix

Update ScalaSttpClientCodegen.encodePath to do name substitution. I will do this and submit a pull request.

Assignee
Assign to
Time tracking