-
Notifications
You must be signed in to change notification settings - Fork 111
Description
(this is a copy of: micronaut-projects/micronaut-gradle-plugin#1162)
Expected Behavior
valid generated kotlin sources from a MS Azure swagger spec
Actual Behaviour
unescaped dollar signs in kotlin code, due to dollar signs in enum values and parameter names, see example:
Java is unaffected.
The Problem is, that kotlin has format Strings, similar to Javascript. A dollar sign, followed by a name (within a string) is assumed to be an existing variable ("$expand" looks for a variable named "expand", same for "$ref").

Steps To Reproduce
for a concise example, use the example yaml, or run functional-tests in the linked project.
swagger: 2.0
info:
title: Dollar Signs ahead
version: 1.0.0
description: might break kotlin
schemes:
- https
produces:
- application/json
consumes:
- application/json
paths:
/dollarSigns:
get:
operationId: getDollarStrings
description: contains $strings
parameters:
- name: $expand
in: query
description: also contains $strings
required: false
type: string
enum:
- ref1/$ref
- ref2/$ref
responses:
"200":
description: succeeded!
schema:
type: string
description: awesome!
default:
description: failed!
schema:
type: string
description: awwwww!
definitions: {}
parameters: {}
Environment Information
N/A
Example Application
https://github.com/einsweniger/micronaut-gradle-plugin/tree/kotlin-dollar_sign_breakage
I am aware, that the issue lies not within the micronaut-gradle-plugin. Unfortunately, the tests here only check for file contents and not if the generated kotlin code can be compiled, so I cannot contribute test breakage in this project, but via the gradle plugin, since that actually runs a kotlin compiler.
If you want to verify this, you can use the linked project and run the
./gradlew :functional-tests:test --tests "io.micronaut.gradle.openapi.OpenApiClientWithKotlinSpec"
to verify the problem.
Version
6.18.1 / 6.17.3