swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

swagger-codegen generate should not generate WARN io.swagger.codegen.DefaultCodegen - Empty operationId found for path: post /foo

Open jan-matejka opened this issue 8 years ago • 5 comments

Description

swagger-codegen generate should not generate WARN io.swagger.codegen.DefaultCodegen - Empty operationId found for path: post /foo

since the spec does not define operationId as required and swagger-codegen can autogenerate value for it.

Or at least a command line option to silence the warning should be provided because now it only makes more difficult to spot issues.

The warning would also be more useful if it shown line number and possibly column. While not essential in this case (the method and path is provided), this threw me off a bit especially at the beggining when I had a lot of warnings.

Swagger-codegen version

current master; HEAD = 1c160df33897898da1c39f230c737eb6a313e6ba

Swagger declaration file content or url
swagger: '2.0'

info:
  title: "sscce"
  version: '1.0'
  description: sscce

definitions:
  foo:
    type: string


paths:
  /foo:
    post:
      parameters:
        - name: foo
          in: body
          schema: {$ref: "#/definitions/foo"}
      responses:
        "200":
          description: foo
          type: string
Command line used for generation

JAR=".../swagger-codegen.git/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" java -jar "${JAR}" generate -i ~/sscce.yaml -l html2 -o foo

outputs:

swagger-codegen generate -i sscce.yaml -l html2 -o sscce.html
[main] INFO io.swagger.parser.Swagger20Parser - reading from sscce.yaml
[main] WARN io.swagger.codegen.DefaultCodegen - Empty operationId found for path: post /foo. Renamed to auto-generated operationId: fooPost
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /home/yac/sscce.html/index.html

jan-matejka avatar Mar 22 '17 16:03 jan-matejka

Any update?

SagarNaliyapara avatar May 09 '19 05:05 SagarNaliyapara

bump

Snazzie avatar Apr 10 '22 00:04 Snazzie

Still relevant

Illutax avatar Nov 07 '23 11:11 Illutax

well you are missing the operationId, or am I missing something?

post:
  summary: Add a new user
  operationId: addUser // <---- this here
  requestBody:
    required: true
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/User'
  responses:
    '201':
      description: User created

mathmul avatar Mar 25 '24 00:03 mathmul

@mathmul

You're missing this sentence from the OP:

since the spec does not define operationId as required and swagger-codegen can autogenerate value for it.

skrysm avatar Mar 26 '24 06:03 skrysm