Skip to content

[Java] Different interface name gets generated by using jaxrs-spec and jaxrs-cxf generators #2889

@zslajosfalvi

Description

@zslajosfalvi

I'm using 4.0.0 version with Maven plugin to generate Java code.

components:

  schemas:
    BaseRequest:
      type: object
      properties:
        sampleField:
          type: string

    Payment:
      type: object
      properties:
        paymentSampleField:
          type: string
    CreditTransferRequest:
      allOf:
        - $ref: '#/components/schemas/BaseRequest'
        - $ref: '#/components/schemas/Payment'

paths:
  /payment:
    post:
      tags:
        - payment-service
      operationId: postCreditTransfer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditTransferRequest'
      responses:
        '200':
          description: ok

By using

<configuration>
  <generateModelTests>false</generateModelTests>
  <generateApiTests>false</generateApiTests>
  <generateSupportingFiles>false</generateSupportingFiles>
  <inputSpec>${project.build.directory}/classes/sample.yaml</inputSpec>
  <skipValidateSpec>true</skipValidateSpec>
  <generatorName>jaxrs-spec</generatorName>
  <output>${project.build.directory}/generated-sources</output>
  <configOptions>
    <sourceFolder>java</sourceFolder>
    <apiPackage>${api.package}</apiPackage>
    <modelPackage>${model.package}</modelPackage>
    <useGenericResponse>true</useGenericResponse>
    <useBeanValidation>false</useBeanValidation>
    <interfaceOnly>true</interfaceOnly>
    <serializableModel>true</serializableModel>
  </configOptions>
</configuration>

the interface generated is

...
public interface PaymentApi
...

By using

<configuration>
  <generateModelTests>false</generateModelTests>
  <generateApiTests>false</generateApiTests>
  <generateSupportingFiles>false</generateSupportingFiles>
  <inputSpec>${project.build.directory}/classes/sample.yaml</inputSpec>
  <skipValidateSpec>true</skipValidateSpec>
  <generatorName>jaxrs-cxf</generatorName>
  <output>${project.build.directory}/generated-sources</output>
  <configOptions>
    <sourceFolder>java</sourceFolder>
    <apiPackage>${api.package}</apiPackage>
    <modelPackage>${model.package}</modelPackage>
    <useGenericResponse>true</useGenericResponse>
    <useBeanValidation>false</useBeanValidation>
    <serializableModel>true</serializableModel>
  </configOptions>
</configuration>

the interface generated is

...
public interface PaymentServiceApi
...

I experimented a bit and found out that jaxrs-spec is using the path for generate the interface name.
This is different to jaxrs-cxf where the tags part is used.

I think this kind of incompatiblity makes hard to change between the 2 generators.
I suggest they should generate the interface name similar way or at least there should be an option with one could directly set a name.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions