添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
风度翩翩的柿子  ·  Scope functions | ...·  1 月前    · 
力能扛鼎的红酒  ·  PHP Checkbox·  5 月前    · 

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 [BUG][KOTLIN] Generated code contains "`" instead of backtick, when using parameters with reserved kotlin names (kotlin-spring) #14026 [BUG][KOTLIN] Generated code contains "`" instead of backtick, when using parameters with reserved kotlin names (kotlin-spring) #14026 martinvisser opened this issue Nov 15, 2022 · 0 comments · Fixed by #14027
  • 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

    Similar issue as #11304 , but for generator kotlin-spring .

    When generating kotlin code using 'kotlin-spring' generator, and one of the parameters is in reserved kotlin names, the generated code contains backtick " " encoded as HTML entity: in the ApiController class:

        @RequestMapping(
            method = [RequestMethod.POST],
            value = ["/annotations"],
            consumes = ["application/json"]
        fun annotate(  @RequestBody &#x60;annotation&#x60;: Annotation): ResponseEntity<Unit> {
            return ResponseEntity(service.annotate(&#x60;annotation&#x60;), HttpStatus.valueOf(200))
    

    And in the API interface:

        fun annotate(&#x60;annotation&#x60;: Annotation): Unit
    openapi-generator version

    6.2.1

    OpenAPI declaration file content or url
    openapi: 3.0.7
    info:
      title: title
      version: '0.0.1'
    paths:
      /annotations:
        post:
          summary: annotate
          requestBody:
            required: true
            content:
              application/json:
                schema:
                  $ref: '#/components/schemas/Annotation'
          responses:
            '200':
              description: OK
    components:
      schemas:
        Annotation:
          type: object
          properties:
              type: string
              format: uuid
    Generation Details

    openapi-generator generate -i openapi.yaml -g kotlin-spring -p serviceInterface=true

    Steps to reproduce

    generate code and open AnnotationsApiController.kt and AnnotationsApiService.kt

    Related issues/PRs

    Related to #11304

    Suggest a fix

    If {{paramName}} is changed to {{{paramName}}} in kotlin-spring/bodyParams.mustache, kotlin-spring/returnValue.mustache and in kotlin-spring/service.mustache the code generates successfully.

    [kotlin] Add fix for wrongly encoded backticks for reserved words when generating kotlin-spring server code #14027 [kotlin] Add fix for wrongly encoded backticks for reserved words when generating kotlin-spring server code martinvisser/openapi-generator