Skip to content

[JaxRS] Code generator does not honor implFolder on windows platform #8113

@selliera

Description

@selliera
Description

When using jaxrs-cxf-cdi and other JaxRS generators, the implFolder config is not honored by hte generator on windows.

The issue is due to file path manipulations in AbstractJavaJAXRSServerCodegen:apiFilename that uses '/' as a separator, while DefaultCodeGen:apiFilename uses File.separator since e7f4fb3 introduced for #7808

Swagger-codegen version

Tested on 2.3.1 and 2.4.0-SNAPSHOT, and this is a regression w.r.t. 2.2.2

Related issues/PRs

The issue that seemingly introduced the regression: #6443

Suggest a fix/enhancement

Use File.separator in AbstractJavaJAXRSServerCodegen:apiFilename

 @Override
  public String apiFilename(String templateName, String tag) {
      String result = super.apiFilename(templateName, tag);

      if ( templateName.endsWith("Impl.mustache") ) {
          int ix = result.lastIndexOf(File.separator);
          result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java";
          result = result.replace(apiFileFolder(), implFileFolder(implFolder));
      } else if ( templateName.endsWith("Factory.mustache") ) {
          int ix = result.lastIndexOf(File.separator);
          result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java";
          result = result.replace(apiFileFolder(), implFileFolder(implFolder));
      } else if ( templateName.endsWith("Service.mustache") ) {
          int ix = result.lastIndexOf('.');
          result = result.substring(0, ix) + "Service.java";
      }
      return result;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions