swagger-api / swagger-api/swagger-codegen

[Java-Spring-server] Syntax error: missing comma.

Open
#8,631 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The generated server code contains a syntax error.

Swagger-codegen version

swagger-codegen-cli-3.0.0-20180717.153005-90

Swagger declaration
openapi: 3.0.0
info:
  version: 0.0.0
  title: Example
paths:
  /randomPet:
    get:
      responses:
        '200':
          description: Random pet
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
security:
  - ApiKeyAuth: []
    AuthorizationProvider: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: REQUIRED.
    AuthorizationProvider:
      type: apiKey
      in: header
      name: AuthorizationProvider
      description: REQUIRED.
  schemas:
    Pet:
      type: object
      required:
        - petType
      properties:
        petType:
          type: string
Command line used for generation
java -jar swagger-codegen-cli-3.0.0-20180717.153005-90.jar generate -DhideGenerationTimestamp=true -l spring -i openapi.yaml
Actual generated code (shortened)
public interface RandomPetApi {
        @Authorization(value = "ApiKeyAuth")@Authorization(value = "AuthorizationProvider")
    }, tags={  })
    ResponseEntity<Pet> randomPetGet();
}
Expected generated code (shortened)
public interface RandomPetApi {
        @Authorization(value = "ApiKeyAuth"),  // This comma is missing in the generated code
        @Authorization(value = "AuthorizationProvider")
    }, tags={  })
    ResponseEntity<Pet> randomPetGet();
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported swagger-codegen CLI command with the provided openapi.yaml, then trace the Spring server generation path that produces RandomPetApi and its authorization annotations. Done means the generated Java interface contains valid comma-separated annotations and no longer has the reported syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.