Skip to content

Commit 67ee557

Browse files
committed
fix: update parameter tables to ensure consistent formatting across API documentation
1 parent 78ceed8 commit 67ee557

104 files changed

Lines changed: 337 additions & 344 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,26 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
10621062
operation.path = operation.path.substring(1);
10631063
}
10641064

1065+
// For jvm-retrofit2, Retrofit @Path names must match [a-zA-Z][a-zA-Z0-9_-]*.
1066+
// When the OpenAPI baseName is invalid (e.g., starts with '$'), replace the
1067+
// URL placeholder with the sanitized paramName and mark via vendor extension.
1068+
if (JVM_RETROFIT2.equals(getLibrary())) {
1069+
for (CodegenParameter param : operation.allParams) {
1070+
if (param.isPathParam) {
1071+
boolean validRetrofitName = param.baseName.matches("[a-zA-Z][a-zA-Z0-9_-]*");
1072+
if (validRetrofitName) {
1073+
param.vendorExtensions.put("x-retrofit-path-name", param.baseName);
1074+
} else {
1075+
param.vendorExtensions.put("x-retrofit-path-name", param.paramName);
1076+
operation.path = operation.path.replace(
1077+
"{" + param.baseName + "}",
1078+
"{" + param.paramName + "}"
1079+
);
1080+
}
1081+
}
1082+
}
1083+
}
1084+
10651085
if (JVM_OKHTTP.equals(getLibrary()) || JVM_OKHTTP4.equals(getLibrary())) {
10661086
// Ideally we would do content negotiation to choose the best mediatype, but that would be a next step.
10671087
// For now we take the first mediatype we can parse and send that.

modules/openapi-generator/src/main/resources/kotlin-client/api_doc.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ try {
4646
This endpoint does not need any parameter.
4747
{{/allParams}}
4848
{{#allParams}}
49-
{{#-last}}
49+
{{#-first}}
5050
| Name | Type | Description | Notes |
5151
| ------------- | ------------- | ------------- | ------------- |
52-
{{/-last}}
52+
{{/-first}}
5353
| **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}| {{#lambda.escapeMarkdown}}{{{unescapedDescription}}}{{/lambda.escapeMarkdown}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{#lambda.escapeMarkdown}}{{{.}}}{{/lambda.escapeMarkdown}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{#lambda.escapeMarkdown}}{{{.}}}{{/lambda.escapeMarkdown}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} |
5454
{{/allParams}}
5555

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api_doc.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ launch(Dispatchers.IO) {
5252
This endpoint does not need any parameter.
5353
{{/allParams}}
5454
{{#allParams}}
55-
{{#-last}}
55+
{{#-first}}
5656
| Name | Type | Description | Notes |
5757
| ------------- | ------------- | ------------- | ------------- |
58-
{{/-last}}
58+
{{/-first}}
5959
| **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}| {{#lambda.escapeMarkdown}}{{{unescapedDescription}}}{{/lambda.escapeMarkdown}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{#lambda.escapeMarkdown}}{{{.}}}{{/lambda.escapeMarkdown}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{#lambda.escapeMarkdown}}{{{.}}}{{/lambda.escapeMarkdown}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} |
6060
{{/allParams}}
6161

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ import okhttp3.MediaType.Companion.toMediaType
134134
okHttpClientBuilder: OkHttpClient.Builder? = null,
135135
{{^kotlinx_serialization}}serializerBuilder: {{#gson}}GsonBuilder{{/gson}}{{#moshi}}Moshi.Builder{{/moshi}}{{#jackson}}ObjectMapper{{/jackson}} = Serializer.{{#gson}}gsonBuilder{{/gson}}{{#moshi}}moshiBuilder{{/moshi}}{{#jackson}}jacksonObjectMapper{{/jackson}},{{/kotlinx_serialization}}
136136
authNames: Array<String>
137-
) : this(baseUrl, okHttpClientBuilder{{^kotlinx_serialization}}, serializerBuilder{{/kotlinx_serialization}}) {
137+
) : this(baseUrl, okHttpClientBuilder{{^kotlinx_serialization}}, {{#generateOneOfAnyOfWrappers}}{{#gson}}registerTypeAdapterFactoryForAllModels(serializerBuilder){{/gson}}{{^gson}}serializerBuilder{{/gson}}{{/generateOneOfAnyOfWrappers}}{{^generateOneOfAnyOfWrappers}}serializerBuilder{{/generateOneOfAnyOfWrappers}}{{/kotlinx_serialization}}) {
138138
authNames.forEach { authName ->
139139
val auth: Interceptor? = when (authName) { {{#authMethods}}
140140
{{#isBasicBasic}}"{{name}}" -> HttpBasicAuth()
@@ -148,21 +148,6 @@ import okhttp3.MediaType.Companion.toMediaType
148148
addAuthorization(authName, auth)
149149
}
150150
}
151-
{{#generateOneOfAnyOfWrappers}}
152-
{{^kotlinx_serialization}}
153-
{{#gson}}
154-
{{#models}}
155-
{{#model}}
156-
{{^isEnum}}
157-
{{^hasChildren}}
158-
serializerBuilder.registerTypeAdapterFactory({{modelPackage}}.{{{classname}}}.CustomTypeAdapterFactory())
159-
{{/hasChildren}}
160-
{{/isEnum}}
161-
{{/model}}
162-
{{/models}}
163-
{{/gson}}
164-
{{/kotlinx_serialization}}
165-
{{/generateOneOfAnyOfWrappers}}
166151
}
167152

168153
{{#authMethods}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#isPathParam}}@Path("{{#lambda.escapeInNormalString}}{{baseName}}{{/lambda.escapeInNormalString}}") {{{paramName}}}: {{{dataType}}}{{#required}}{{#defaultValue}} = {{^isNumber}}{{#isString}}{{^allowableValues}}"{{#lambda.escapeInNormalString}}{{{unescapedDefaultValue}}}{{/lambda.escapeInNormalString}}"{{/allowableValues}}{{#allowableValues}}{{{defaultValue}}}{{/allowableValues}}{{/isString}}{{^isString}}{{{defaultValue}}}{{/isString}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{/required}}{{^required}}?{{#defaultValue}} = {{^isNumber}}{{#isString}}{{^allowableValues}}"{{#lambda.escapeInNormalString}}{{{unescapedDefaultValue}}}{{/lambda.escapeInNormalString}}"{{/allowableValues}}{{#allowableValues}}{{{defaultValue}}}{{/allowableValues}}{{/isString}}{{^isString}}{{{defaultValue}}}{{/isString}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}}{{/isPathParam}}
1+
{{#isPathParam}}@Path("{{{vendorExtensions.x-retrofit-path-name}}}") {{{paramName}}}: {{{dataType}}}{{#required}}{{#defaultValue}} = {{^isNumber}}{{#isString}}{{^allowableValues}}"{{#lambda.escapeInNormalString}}{{{unescapedDefaultValue}}}{{/lambda.escapeInNormalString}}"{{/allowableValues}}{{#allowableValues}}{{{defaultValue}}}{{/allowableValues}}{{/isString}}{{^isString}}{{{defaultValue}}}{{/isString}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{/required}}{{^required}}?{{#defaultValue}} = {{^isNumber}}{{#isString}}{{^allowableValues}}"{{#lambda.escapeInNormalString}}{{{unescapedDefaultValue}}}{{/lambda.escapeInNormalString}}"{{/allowableValues}}{{#allowableValues}}{{{defaultValue}}}{{/allowableValues}}{{/isString}}{{^isString}}{{{defaultValue}}}{{/isString}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}}{{/isPathParam}}

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-volley/api_doc.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ launch(Dispatchers.IO) {
4848
```
4949

5050
### Parameters
51-
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
51+
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-first}}
5252
Name | Type | Description | Notes
53-
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
53+
------------- | ------------- | ------------- | -------------{{/-first}}{{/allParams}}
5454
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}| {{#lambda.escapeMarkdown}}{{{unescapedDescription}}}{{/lambda.escapeMarkdown}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{{defaultValue}}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{#lambda.escapeMarkdown}}{{{.}}}{{/lambda.escapeMarkdown}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}}
5555
{{/allParams}}
5656

samples/client/echo_api/kotlin-jvm-okhttp/docs/EchoApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ try {
3737
```
3838

3939
### Parameters
40-
| **dollarParamName** | **kotlin.String**| | |
4140
| Name | Type | Description | Notes |
4241
| ------------- | ------------- | ------------- | ------------- |
42+
| **dollarParamName** | **kotlin.String**| | |
4343
| **filterDollarType** | **kotlin.String**| Filter with \$dollar in description and comment-close */ | [optional] [default to "default\$Value with \\\\ and \\""] |
4444

4545
### Return type

samples/client/echo_api/kotlin-jvm-okhttp/docs/FormApi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ try {
3939
```
4040

4141
### Parameters
42-
| **integerForm** | **kotlin.Int**| | [optional] |
43-
| **booleanForm** | **kotlin.Boolean**| | [optional] |
4442
| Name | Type | Description | Notes |
4543
| ------------- | ------------- | ------------- | ------------- |
44+
| **integerForm** | **kotlin.Int**| | [optional] |
45+
| **booleanForm** | **kotlin.Boolean**| | [optional] |
4646
| **stringForm** | **kotlin.String**| | [optional] |
4747

4848
### Return type
@@ -92,13 +92,13 @@ try {
9292
```
9393

9494
### Parameters
95+
| Name | Type | Description | Notes |
96+
| ------------- | ------------- | ------------- | ------------- |
9597
| **form1** | **kotlin.String**| | [optional] |
9698
| **form2** | **kotlin.Int**| | [optional] |
9799
| **form3** | **kotlin.String**| | [optional] |
98100
| **form4** | **kotlin.Boolean**| | [optional] |
99101
| **id** | **kotlin.Long**| | [optional] |
100-
| Name | Type | Description | Notes |
101-
| ------------- | ------------- | ------------- | ------------- |
102102
| **name** | **kotlin.String**| | [optional] |
103103

104104
### Return type

samples/client/echo_api/kotlin-jvm-okhttp/docs/HeaderApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ try {
4040
```
4141

4242
### Parameters
43+
| Name | Type | Description | Notes |
44+
| ------------- | ------------- | ------------- | ------------- |
4345
| **integerHeader** | **kotlin.Int**| | [optional] |
4446
| **booleanHeader** | **kotlin.Boolean**| | [optional] |
4547
| **stringHeader** | **kotlin.String**| | [optional] |
4648
| **enumNonrefStringHeader** | **kotlin.String**| | [optional] [enum: success, failure, unclassified] |
47-
| Name | Type | Description | Notes |
48-
| ------------- | ------------- | ------------- | ------------- |
4949
| **enumRefStringHeader** | [**ApiStringEnumRef**](.md)| | [optional] [enum: success, failure, unclassified] |
5050

5151
### Return type

samples/client/echo_api/kotlin-jvm-okhttp/docs/PathApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ try {
3939
```
4040

4141
### Parameters
42+
| Name | Type | Description | Notes |
43+
| ------------- | ------------- | ------------- | ------------- |
4244
| **pathString** | **kotlin.String**| | |
4345
| **pathInteger** | **kotlin.Int**| | |
4446
| **enumNonrefStringPath** | **kotlin.String**| | [enum: success, failure, unclassified] |
45-
| Name | Type | Description | Notes |
46-
| ------------- | ------------- | ------------- | ------------- |
4747
| **enumRefStringPath** | [**ApiStringEnumRef**](.md)| | [enum: success, failure, unclassified] |
4848

4949
### Return type

0 commit comments

Comments
 (0)