Skip to content

Commit f4d1198

Browse files
authored
remove backslash from path (#24723)
1 parent a783d24 commit f4d1198

6 files changed

Lines changed: 187 additions & 0 deletions

File tree

‎modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4849,6 +4849,8 @@ public CodegenOperation fromOperation(String path,
48494849
} else {
48504850
op.path = path;
48514851
}
4852+
// remove backslash from path, e.g. /api/v2/GetPetById\\(\\) => /api/v2/GetPetById()
4853+
op.path = op.path.replace("\\", "");
48524854

48534855
op.summary = escapeText(operation.getSummary());
48544856
op.unescapedNotes = operation.getDescription();

‎modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,13 @@ paths:
758758
items:
759759
"$ref": "#/components/schemas/myObject"
760760
- type: 'null'
761+
"/fake/path/backslash/GetPetById\\(\\)":
762+
get:
763+
tags:
764+
- fake
765+
responses:
766+
'200':
767+
description: ''
761768
externalDocs:
762769
description: Find out more about Swagger
763770
url: 'http://swagger.io'

‎samples/client/petstore/java/okhttp-gson-3.1/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Class | Method | HTTP request | Description
116116
*FakeApi* | [**fakeInlineSchemaAnyofPath1Get**](docs/FakeApi.md#fakeInlineSchemaAnyofPath1Get) | **GET** /fake/inline/schema/anyof/path1 |
117117
*FakeApi* | [**fakeInlineSchemaAnyofPath2Get**](docs/FakeApi.md#fakeInlineSchemaAnyofPath2Get) | **GET** /fake/inline/schema/anyof/path2 |
118118
*FakeApi* | [**fakeInlineSchemaAnyofPath3Get**](docs/FakeApi.md#fakeInlineSchemaAnyofPath3Get) | **GET** /fake/inline/schema/anyof/path3 |
119+
*FakeApi* | [**fakePathBackslashGetPetByIdGet**](docs/FakeApi.md#fakePathBackslashGetPetByIdGet) | **GET** /fake/path/backslash/GetPetById() |
119120
*FakeApi* | [**op1**](docs/FakeApi.md#op1) | **POST** /fake/api/changeowner | op1
120121
*FakeApi* | [**op2**](docs/FakeApi.md#op2) | **POST** /fake/api/changename | op2
121122
*FakeApi* | [**op3**](docs/FakeApi.md#op3) | **POST** /fake/api/query/enum | op3

‎samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,15 @@ paths:
834834
- fake
835835
x-accepts:
836836
- application/json
837+
/fake/path/backslash/GetPetById\(\):
838+
get:
839+
responses:
840+
"200":
841+
description: ""
842+
tags:
843+
- fake
844+
x-accepts:
845+
- application/json
837846
components:
838847
parameters:
839848
ref_to_uuid:

‎samples/client/petstore/java/okhttp-gson-3.1/docs/FakeApi.md‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
77
| [**fakeInlineSchemaAnyofPath1Get**](FakeApi.md#fakeInlineSchemaAnyofPath1Get) | **GET** /fake/inline/schema/anyof/path1 | |
88
| [**fakeInlineSchemaAnyofPath2Get**](FakeApi.md#fakeInlineSchemaAnyofPath2Get) | **GET** /fake/inline/schema/anyof/path2 | |
99
| [**fakeInlineSchemaAnyofPath3Get**](FakeApi.md#fakeInlineSchemaAnyofPath3Get) | **GET** /fake/inline/schema/anyof/path3 | |
10+
| [**fakePathBackslashGetPetByIdGet**](FakeApi.md#fakePathBackslashGetPetByIdGet) | **GET** /fake/path/backslash/GetPetById() | |
1011
| [**op1**](FakeApi.md#op1) | **POST** /fake/api/changeowner | op1 |
1112
| [**op2**](FakeApi.md#op2) | **POST** /fake/api/changename | op2 |
1213
| [**op3**](FakeApi.md#op3) | **POST** /fake/api/query/enum | op3 |
@@ -186,6 +187,61 @@ No authorization required
186187
|-------------|-------------|------------------|
187188
| **200** | | - |
188189

190+
<a id="fakePathBackslashGetPetByIdGet"></a>
191+
# **fakePathBackslashGetPetByIdGet**
192+
> fakePathBackslashGetPetByIdGet()
193+
194+
195+
196+
### Example
197+
```java
198+
// Import classes:
199+
import org.openapitools.client.ApiClient;
200+
import org.openapitools.client.ApiException;
201+
import org.openapitools.client.Configuration;
202+
import org.openapitools.client.models.*;
203+
import org.openapitools.client.api.FakeApi;
204+
205+
public class Example {
206+
public static void main(String[] args) {
207+
ApiClient defaultClient = Configuration.getDefaultApiClient();
208+
defaultClient.setBasePath("http://petstore.swagger.io/v2");
209+
210+
FakeApi apiInstance = new FakeApi(defaultClient);
211+
try {
212+
apiInstance.fakePathBackslashGetPetByIdGet();
213+
} catch (ApiException e) {
214+
System.err.println("Exception when calling FakeApi#fakePathBackslashGetPetByIdGet");
215+
System.err.println("Status code: " + e.getCode());
216+
System.err.println("Reason: " + e.getResponseBody());
217+
System.err.println("Response headers: " + e.getResponseHeaders());
218+
e.printStackTrace();
219+
}
220+
}
221+
}
222+
```
223+
224+
### Parameters
225+
This endpoint does not need any parameter.
226+
227+
### Return type
228+
229+
null (empty response body)
230+
231+
### Authorization
232+
233+
No authorization required
234+
235+
### HTTP request headers
236+
237+
- **Content-Type**: Not defined
238+
- **Accept**: Not defined
239+
240+
### HTTP response details
241+
| Status code | Description | Response headers |
242+
|-------------|-------------|------------------|
243+
| **200** | | - |
244+
189245
<a id="op1"></a>
190246
# **op1**
191247
> Object op1()

‎samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/FakeApi.java‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,118 @@ public okhttp3.Call fakeInlineSchemaAnyofPath3GetAsync(final ApiCallback<List<Ob
426426
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
427427
return localVarCall;
428428
}
429+
/**
430+
* Build call for fakePathBackslashGetPetByIdGet
431+
* @param _callback Callback for upload/download progress
432+
* @return Call to execute
433+
* @throws ApiException If fail to serialize the request body object
434+
* @http.response.details
435+
<table border="1">
436+
<caption>Response Details</caption>
437+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
438+
<tr><td> 200 </td><td> </td><td> - </td></tr>
439+
</table>
440+
*/
441+
public okhttp3.Call fakePathBackslashGetPetByIdGetCall(final ApiCallback _callback) throws ApiException {
442+
String basePath = null;
443+
// Operation Servers
444+
String[] localBasePaths = new String[] { };
445+
446+
// Determine Base Path to Use
447+
if (localCustomBaseUrl != null){
448+
basePath = localCustomBaseUrl;
449+
} else if ( localBasePaths.length > 0 ) {
450+
basePath = localBasePaths[localHostIndex];
451+
} else {
452+
basePath = null;
453+
}
454+
455+
Object localVarPostBody = null;
456+
457+
// create path and map variables
458+
String localVarPath = "/fake/path/backslash/GetPetById()";
459+
460+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
461+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
462+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
463+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
464+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
465+
466+
final String[] localVarAccepts = {
467+
};
468+
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
469+
if (localVarAccept != null) {
470+
localVarHeaderParams.put("Accept", localVarAccept);
471+
}
472+
473+
final String[] localVarContentTypes = {
474+
};
475+
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
476+
if (localVarContentType != null) {
477+
localVarHeaderParams.put("Content-Type", localVarContentType);
478+
}
479+
480+
String[] localVarAuthNames = new String[] { };
481+
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
482+
}
483+
484+
@SuppressWarnings("rawtypes")
485+
private okhttp3.Call fakePathBackslashGetPetByIdGetValidateBeforeCall(final ApiCallback _callback) throws ApiException {
486+
return fakePathBackslashGetPetByIdGetCall(_callback);
487+
488+
}
489+
490+
/**
491+
*
492+
*
493+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
494+
* @http.response.details
495+
<table border="1">
496+
<caption>Response Details</caption>
497+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
498+
<tr><td> 200 </td><td> </td><td> - </td></tr>
499+
</table>
500+
*/
501+
public void fakePathBackslashGetPetByIdGet() throws ApiException {
502+
fakePathBackslashGetPetByIdGetWithHttpInfo();
503+
}
504+
505+
/**
506+
*
507+
*
508+
* @return ApiResponse&lt;Void&gt;
509+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
510+
* @http.response.details
511+
<table border="1">
512+
<caption>Response Details</caption>
513+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
514+
<tr><td> 200 </td><td> </td><td> - </td></tr>
515+
</table>
516+
*/
517+
public ApiResponse<Void> fakePathBackslashGetPetByIdGetWithHttpInfo() throws ApiException {
518+
okhttp3.Call localVarCall = fakePathBackslashGetPetByIdGetValidateBeforeCall(null);
519+
return localVarApiClient.execute(localVarCall);
520+
}
521+
522+
/**
523+
* (asynchronously)
524+
*
525+
* @param _callback The callback to be executed when the API call finishes
526+
* @return The request call
527+
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
528+
* @http.response.details
529+
<table border="1">
530+
<caption>Response Details</caption>
531+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
532+
<tr><td> 200 </td><td> </td><td> - </td></tr>
533+
</table>
534+
*/
535+
public okhttp3.Call fakePathBackslashGetPetByIdGetAsync(final ApiCallback<Void> _callback) throws ApiException {
536+
537+
okhttp3.Call localVarCall = fakePathBackslashGetPetByIdGetValidateBeforeCall(_callback);
538+
localVarApiClient.executeAsync(localVarCall, _callback);
539+
return localVarCall;
540+
}
429541
/**
430542
* Build call for op1
431543
* @param _callback Callback for upload/download progress

0 commit comments

Comments
 (0)