openapi-processor / openapi-processor-core

moved into openapi-processor-base
Apache License 2.0
7 stars 5 forks source link

Lost API #35

Closed schlagi123 closed 3 years ago

schlagi123 commented 3 years ago

If I use the following YAML:

openapi: 3.0.2
info:
  title: name me
  version: 1.0.0

paths:
  /api/test1:
    get:
      summary: Test.
      operationId: test_1
      tags:
        - test_api
      responses:
        200:
          description: Test

  /api/test2:
    get:
      summary: Test.
      operationId: test_2
      tags:
        - test-api
      responses:
        200:
          description: Test

The difference of the apis are the tag (test_api and test-api). One api of the two is lost in the result. I had excepted, that I get...

But currently one api is lost.

hauner commented 3 years ago

The processor uses the first tag to create the interface name. To create a valid java identifier it drops the - in test-api and the _ in test_api finally using TestApi as the interface name.

Hmm, looking at the code it is using the raw tag names (i.e. test-api) to collect the methods of an interface and the java identifier to generate the source file. It means that the first interface is probably lost because it gets overwritten by the second with the same name.

The fix (using the java identifier to select the target interface) will add both endpoints to the same interface.