From 32296f40f3de526fb8c8fb9e21a9673d70bb9340 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 17 Aug 2026 17:51:08 +0800 Subject: [PATCH] remove backslash from path --- .../openapitools/codegen/DefaultCodegen.java | 2 + .../src/test/resources/3_1/java/petstore.yaml | 7 ++ .../petstore/java/okhttp-gson-3.1/README.md | 1 + .../java/okhttp-gson-3.1/api/openapi.yaml | 9 ++ .../java/okhttp-gson-3.1/docs/FakeApi.md | 56 +++++++++ .../org/openapitools/client/api/FakeApi.java | 112 ++++++++++++++++++ 6 files changed, 187 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 6d6c631aec1e..9a5b8752c719 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -4849,6 +4849,8 @@ public CodegenOperation fromOperation(String path, } else { op.path = path; } + // remove backslash from path, e.g. /api/v2/GetPetById\\(\\) => /api/v2/GetPetById() + op.path = op.path.replace("\\", ""); op.summary = escapeText(operation.getSummary()); op.unescapedNotes = operation.getDescription(); diff --git a/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml b/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml index 704dc12186d9..289489356c19 100644 --- a/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml @@ -758,6 +758,13 @@ paths: items: "$ref": "#/components/schemas/myObject" - type: 'null' + "/fake/path/backslash/GetPetById\\(\\)": + get: + tags: + - fake + responses: + '200': + description: '' externalDocs: description: Find out more about Swagger url: 'http://swagger.io' diff --git a/samples/client/petstore/java/okhttp-gson-3.1/README.md b/samples/client/petstore/java/okhttp-gson-3.1/README.md index 323f47a8c822..d5b9aa7acf13 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/README.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/README.md @@ -116,6 +116,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**fakeInlineSchemaAnyofPath1Get**](docs/FakeApi.md#fakeInlineSchemaAnyofPath1Get) | **GET** /fake/inline/schema/anyof/path1 | *FakeApi* | [**fakeInlineSchemaAnyofPath2Get**](docs/FakeApi.md#fakeInlineSchemaAnyofPath2Get) | **GET** /fake/inline/schema/anyof/path2 | *FakeApi* | [**fakeInlineSchemaAnyofPath3Get**](docs/FakeApi.md#fakeInlineSchemaAnyofPath3Get) | **GET** /fake/inline/schema/anyof/path3 | +*FakeApi* | [**fakePathBackslashGetPetByIdGet**](docs/FakeApi.md#fakePathBackslashGetPetByIdGet) | **GET** /fake/path/backslash/GetPetById() | *FakeApi* | [**op1**](docs/FakeApi.md#op1) | **POST** /fake/api/changeowner | op1 *FakeApi* | [**op2**](docs/FakeApi.md#op2) | **POST** /fake/api/changename | op2 *FakeApi* | [**op3**](docs/FakeApi.md#op3) | **POST** /fake/api/query/enum | op3 diff --git a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml index 45d0e4167627..82069b6831c1 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml @@ -834,6 +834,15 @@ paths: - fake x-accepts: - application/json + /fake/path/backslash/GetPetById\(\): + get: + responses: + "200": + description: "" + tags: + - fake + x-accepts: + - application/json components: parameters: ref_to_uuid: diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md index 684e019ef94d..79cb9e4dd28f 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md @@ -7,6 +7,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* | [**fakeInlineSchemaAnyofPath1Get**](FakeApi.md#fakeInlineSchemaAnyofPath1Get) | **GET** /fake/inline/schema/anyof/path1 | | | [**fakeInlineSchemaAnyofPath2Get**](FakeApi.md#fakeInlineSchemaAnyofPath2Get) | **GET** /fake/inline/schema/anyof/path2 | | | [**fakeInlineSchemaAnyofPath3Get**](FakeApi.md#fakeInlineSchemaAnyofPath3Get) | **GET** /fake/inline/schema/anyof/path3 | | +| [**fakePathBackslashGetPetByIdGet**](FakeApi.md#fakePathBackslashGetPetByIdGet) | **GET** /fake/path/backslash/GetPetById() | | | [**op1**](FakeApi.md#op1) | **POST** /fake/api/changeowner | op1 | | [**op2**](FakeApi.md#op2) | **POST** /fake/api/changename | op2 | | [**op3**](FakeApi.md#op3) | **POST** /fake/api/query/enum | op3 | @@ -186,6 +187,61 @@ No authorization required |-------------|-------------|------------------| | **200** | | - | + +# **fakePathBackslashGetPetByIdGet** +> fakePathBackslashGetPetByIdGet() + + + +### Example +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + try { + apiInstance.fakePathBackslashGetPetByIdGet(); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakePathBackslashGetPetByIdGet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | | - | + # **op1** > Object op1() diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java index eefccaf26854..afe7f7bfea57 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java @@ -426,6 +426,118 @@ public okhttp3.Call fakeInlineSchemaAnyofPath3GetAsync(final ApiCallback + Response Details + Status Code Description Response Headers + 200 - + + */ + public okhttp3.Call fakePathBackslashGetPetByIdGetCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/fake/path/backslash/GetPetById()"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call fakePathBackslashGetPetByIdGetValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return fakePathBackslashGetPetByIdGetCall(_callback); + + } + + /** + * + * + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Response Details
Status Code Description Response Headers
200 -
+ */ + public void fakePathBackslashGetPetByIdGet() throws ApiException { + fakePathBackslashGetPetByIdGetWithHttpInfo(); + } + + /** + * + * + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Response Details
Status Code Description Response Headers
200 -
+ */ + public ApiResponse fakePathBackslashGetPetByIdGetWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = fakePathBackslashGetPetByIdGetValidateBeforeCall(null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + +
Response Details
Status Code Description Response Headers
200 -
+ */ + public okhttp3.Call fakePathBackslashGetPetByIdGetAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = fakePathBackslashGetPetByIdGetValidateBeforeCall(_callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } /** * Build call for op1 * @param _callback Callback for upload/download progress