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

Support wider range of chars in param names in codegen #3059

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ class EndpointGenerator {
|""".stripMargin

val name = m.operationId
.getOrElse(m.methodType + p.url.split('/').map(_.replace("{", "").replace("}", "").toLowerCase.capitalize).mkString)
.getOrElse(m.methodType + p.url.capitalize)
.split("[^0-9a-zA-Z$_]")
.filter(_.nonEmpty)
.zipWithIndex
.map { case (part, 0) => part; case (part, _) => part.capitalize }
.mkString
(name, definition)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class EndpointGeneratorSpec extends CompileCheckTestBase {
null,
Seq(
OpenapiPath(
"test/{asd}",
"test/{asd-id}",
Seq(
OpenapiPathMethod(
methodType = "get",
parameters = Seq(OpenapiParameter("asd", "path", true, None, OpenapiSchemaString(false))),
parameters = Seq(OpenapiParameter("asd-id", "path", true, None, OpenapiSchemaString(false))),
responses = Seq(
OpenapiResponse(
"200",
Expand All @@ -41,8 +41,9 @@ class EndpointGeneratorSpec extends CompileCheckTestBase {
),
null
)
BasicGenerator.imports ++
new EndpointGenerator().endpointDefs(doc) shouldCompile ()
val generatedCode = BasicGenerator.imports ++ new EndpointGenerator().endpointDefs(doc)
generatedCode should include ("val getTestAsdId =")
generatedCode shouldCompile ()
}

}