Skip to content

Commit 2859fca

Browse files
Denis-AverinTimurBaiguskarovAsposeivankamkin
authored
Separate args into groups (#152)
* Update codegen for API 26.6 * Fix Java wrapper import template * Ignore release tag URLs in URL check * Release 26.6 * Split generate params into groups * Update spec * Dart templates fixed for new spec * Fixed dotnet templates * Templates fixed for new spec * Fix java template * Fix node template * Fix php templates * Fix python templates * Fix swift template * Update java template * Fix Java templates * Update Swift templates * Fix Swift templates again * Add .spi.yml for Swift * Generate the Node.js SDK in a single openapi-generator run typescript-node cannot emit docs on its own, so models.ts, the docs and the README were produced by a second generator invocation that reused the api.ts/git_push.sh/tsconfig.json output slots. Emit them as user-defined supporting files (config-node.json "files" section) so everything is produced in one run, and rename the templates to match their output. * Emit Java, .NET, and Go SDK support files via the files config These generators produced a file under an unrelated built-in name (git_push.sh, appveyor.yml, response.go) and moved it into place. Emit each at its real name via the config "files" section and rename the templates to match. For Go, drop the generator's default response.go before the wildcard move so it is not pulled into the SDK. * Rework the Android SDK templates for the files config and grouped API Emit gradle.properties, app/build.gradle and MainActivity.kt via the files config instead of hijacking the git_push.sh/gradlew/ApiException.java slots (settings.gradle overrides the built-in template directly). Update the MainActivity and README sample to the grouped generate() API (barcodeImageParams/qrParams) to match the current SDK. * Point the Go SDK badges at the v4 module and branch Replace the Go Report Card badge with the pkg.go.dev Go Reference badge for the v4 module, and point the CI status badge at the v4 branch. * Drop dead boilerplate from the Go SDK utils.go template utils.go shipped only unused openapi-generator helpers (Ptr*, Nullable*, IsNil, newStrictDecoder). Emit an empty utils.go from a trimmed template. * Restrict the CI badge branch check to main or v4 Previously only ?branch=main passed. Accept ?branch=main or ?branch=v4 (the Go SDK's default branch); flag any other branch, a missing branch, or prefixes like v40. * Update submodules * Refresh the spec from the live API and drop inject-param-groups The API now serves the x-param-group vendor extensions itself, so inject-param-groups.py only re-serialised the fetched JSON ({ } -> {}, trailing newline), drifting the committed spec from live and failing the check-swagger CI job on every 'make update'. Remove the script and its callers (update_swagger_spec.bash, the Makefile spec-param-groups target); the fetched spec needs no post-processing. * Ignore .example domains in the URL checker Add the reserved .example TLD to the URL checker's ignore list; also apply isort/black formatting. * Ignore incorrect URLs from tests --------- Co-authored-by: Timur Baiguskarov <timur.baiguskarov@aspose.com> Co-authored-by: Ivan Kamkin <ivan.kamkin@aspose.com>
1 parent b6f71ff commit 2859fca

59 files changed

Lines changed: 1861 additions & 248 deletions

Some content is hidden

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

codegen/Templates/android/apiException.mustache renamed to codegen/Templates/android/MainActivity.kt.mustache

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ import com.aspose.barcode.cloud.ApiException
2929
import com.aspose.barcode.cloud.api.GenerateApi
3030
import com.aspose.barcode.cloud.api.ScanApi
3131
import com.aspose.barcode.cloud.model.BarcodeImageFormat
32+
import com.aspose.barcode.cloud.model.BarcodeImageParams
3233
import com.aspose.barcode.cloud.model.EncodeBarcodeType
34+
import com.aspose.barcode.cloud.model.QREncodeMode
35+
import com.aspose.barcode.cloud.model.QRErrorLevel
36+
import com.aspose.barcode.cloud.model.QRVersion
37+
import com.aspose.barcode.cloud.model.QrParams
3338
import com.aspose.barcode.cloud.requests.GenerateRequestWrapper
3439
import com.aspose.barcode.cloud.requests.ScanMultipartRequestWrapper
3540
import com.google.android.material.snackbar.Snackbar
@@ -227,9 +232,20 @@ class MainActivity : AppCompatActivity() {
227232
val type = EncodeBarcodeType.fromValue(barcodeTypeSpinner.selectedItem.toString())
228233
229234
val genRequest = GenerateRequestWrapper(type, barcodeTextEdit.text.toString())
230-
genRequest.imageFormat = BarcodeImageFormat.PNG
231-
genRequest.imageHeight = barcodeImgView.measuredHeight.toFloat()
232-
genRequest.imageWidth = barcodeImgView.measuredWidth.toFloat()
235+
genRequest.barcodeImageParams = BarcodeImageParams().apply {
236+
imageFormat = BarcodeImageFormat.PNG
237+
imageHeight = barcodeImgView.measuredHeight.toFloat()
238+
imageWidth = barcodeImgView.measuredWidth.toFloat()
239+
}
240+
241+
if (type == EncodeBarcodeType.QR) {
242+
genRequest.qrParams = QrParams().apply {
243+
qrEncodeMode = QREncodeMode.AUTO
244+
qrErrorLevel = QRErrorLevel.LEVEL_M
245+
qrVersion = QRVersion.AUTO
246+
qrAspectRatio = 0.75f
247+
}
248+
}
233249

234250
Thread {
235251
try {

codegen/Templates/android/README.mustache

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,31 @@ To use Aspose Barcode Cloud for Android you need to register an account with [As
7070

7171
## Getting Started
7272

73-
- Open project in Android Studio
73+
- Open project in Android Studio.
7474

75-
- Go to file *app/src/main/java/com/example/asposebarcodecloud/MainActivity.kt* and set *clientId* and *clientSecret* to apropriate values from <https://dashboard.aspose.cloud/applications>
75+
- Go to `app/src/main/java/com/aspose/barcode/cloud/demo_app/MainActivity.kt` and set your `clientId` and `clientSecret` from <https://dashboard.aspose.cloud/applications>.
7676

77-
- Build project and run application on connected device or emulator.
77+
- Build the project and run the app on a connected device or emulator.
7878

79-
## Generate Code128 BbarCode in Android using Java
79+
## Generate QR Barcode in Android using Kotlin
8080

81-
```java
82-
// Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).
83-
ApiClient client = new ApiClient("MY_CLIENT_ID", "MY_CLIENT_SECRET");
81+
```kotlin
82+
val client = ApiClient("MY_CLIENT_ID", "MY_CLIENT_SECRET")
83+
val generateApi = GenerateApi(client)
8484

85-
BarcodeApi api = new BarcodeApi(client);
85+
val request = GenerateRequestWrapper(EncodeBarcodeType.QR, "text example")
86+
request.barcodeImageParams = BarcodeImageParams().apply {
87+
imageFormat = BarcodeImageFormat.PNG
88+
}
89+
request.qrParams = QrParams().apply {
90+
qrEncodeMode = QREncodeMode.AUTO
91+
qrErrorLevel = QRErrorLevel.LEVEL_M
92+
qrVersion = QRVersion.AUTO
93+
qrAspectRatio = 0.75f
94+
}
8695

87-
String type = "code128";
88-
String text = "text example";
89-
90-
File result = api.getBarcodeGenerate(type, text);
91-
System.out.println(result);
96+
val result = generateApi.generate(request)
97+
println(result?.absolutePath)
9298
```
9399

94100
## Licensing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

codegen/Templates/csharp/api.mustache

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,22 @@ namespace {{packageName}}.Api
6464
/// <summary>
6565
/// {{summary}} {{notes}}
6666
/// </summary>
67-
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
67+
{{#allParams}}
68+
{{^vendorExtensions.x-param-group-camel}}
69+
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
70+
{{/vendorExtensions.x-param-group-camel}}
6871
{{/allParams}}
72+
{{#vendorExtensions.x-param-groups}}
73+
/// <param name="{{camel}}">Grouped parameters of type {{type}} (optional)</param>
74+
{{/vendorExtensions.x-param-groups}}
6975
/// <param name="cancellationToken"></param>
7076
/// <returns>
7177
/// A task that represents the asynchronous operation. {{#returnType}}Task result type is <see cref="{{returnType}}" /> {{/returnType}}
7278
/// </returns>
7379
{{#isDeprecated}}
7480
[Obsolete]
7581
{{/isDeprecated}}
76-
public async {{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default)
82+
public async {{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async({{#allParams}}{{^vendorExtensions.x-param-group-camel}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}, {{/vendorExtensions.x-param-group-camel}}{{/allParams}}{{#vendorExtensions.x-param-groups}}{{type}} {{camel}} = default, {{/vendorExtensions.x-param-groups}}System.Threading.CancellationToken cancellationToken = default)
7783
{
7884
{{#allParams}}{{#required}}{{^isEnum}} // verify the required parameter '{{paramName}}' is set
7985
if ({{paramName}} == null)
@@ -87,17 +93,22 @@ namespace {{packageName}}.Api
8793
.Replace("&amp;", "&")
8894
.Replace("/?", "?");
8995
{{#headerParams}}
90-
{{#-first}}Dictionary<string, string> headerParams = new Dictionary<string, string>();{{/-first}}
96+
{{#-first}}
97+
Dictionary<string, string> headerParams = new Dictionary<string, string>();
98+
{{/-first}}
9199
{{/headerParams}}
92100
{{#formParams}}
93-
{{#-first}}MultipartFormDataContent multipartContent = new MultipartFormDataContent();{{/-first}}
101+
{{#-first}}
102+
MultipartFormDataContent multipartContent = new MultipartFormDataContent();
103+
{{/-first}}
104+
{{^vendorExtensions.x-param-group-camel}}
94105
{{^isEnum}}
95106
if ({{paramName}} != null)
96107
{ {{/isEnum}} {{#isEnum}}{{^required}}if ({{paramName}} != null) { {{/required}}{{/isEnum}}
97108
{{#isFile}}
98109
{{^required}}
99110
if ({{paramName}} != null)
100-
{ {{/required}}
111+
{ {{/required}}
101112
multipartContent.Add(new StreamContent({{paramName}}), "{{paramName}}", "{{paramName}}.png");
102113
{{^required}} } {{/required}}
103114
{{/isFile}}
@@ -113,14 +124,25 @@ namespace {{packageName}}.Api
113124
{{/isPrimitiveType}}
114125
{{/isFile}}
115126
{{^isEnum}} } {{/isEnum}} {{#isEnum}}{{^required}} } {{/required}}{{/isEnum}}
127+
{{/vendorExtensions.x-param-group-camel}}
128+
{{#vendorExtensions.x-param-group-camel}}
129+
if ({{vendorExtensions.x-param-group-camel}}?.{{nameInPascalCase}} != null)
130+
{
131+
multipartContent.Add(new StringContent($"{ {{vendorExtensions.x-param-group-camel}}?.{{nameInPascalCase}} }"), "{{paramName}}");
132+
}
133+
{{/vendorExtensions.x-param-group-camel}}
116134
{{/formParams}}
117135
{{#pathParams}}
118136
resourcePath = UrlHelper.AddPathParameter(resourcePath, "{{paramName}}", {{paramName}});
119137
{{/pathParams}}
120138
{{#queryParams}}
121-
{{#-first}}#pragma warning disable CS0618 // Type or member is obsolete{{/-first}}
122-
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "{{paramName}}", {{paramName}});
123-
{{#-last}}#pragma warning restore CS0618 // Type or member is obsolete{{/-last}}
139+
{{#-first}}
140+
#pragma warning disable CS0618 // Type or member is obsolete
141+
{{/-first}}
142+
{{^vendorExtensions.x-param-group-camel}}resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "{{paramName}}", {{paramName}});{{/vendorExtensions.x-param-group-camel}}{{#vendorExtensions.x-param-group-camel}}resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "{{paramName}}", {{vendorExtensions.x-param-group-camel}}?.{{nameInPascalCase}});{{/vendorExtensions.x-param-group-camel}}
143+
{{#-last}}
144+
#pragma warning restore CS0618 // Type or member is obsolete
145+
{{/-last}}
124146
{{/queryParams}}
125147
{{#hasBodyParam}}string postBody = SerializationHelper.Serialize({{bodyParam.paramName}}); // http body (model) parameter{{/hasBodyParam}}
126148

codegen/Templates/csharp/api_test.mustache

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ namespace {{packageName}}.Interfaces
2222
/// </remarks>
2323
/// <exception cref="{{packageName}}.Api.ApiException">Thrown when fails to make API call</exception>
2424
{{#allParams}}
25-
/// <param name="{{paramName}}">{{description}}</param>
25+
{{^vendorExtensions.x-param-group-camel}}/// <param name="{{paramName}}">{{description}}</param>{{/vendorExtensions.x-param-group-camel}}
2626
{{/allParams}}
27+
{{#vendorExtensions.x-param-groups}}
28+
/// <param name="{{camel}}">Grouped parameters of type {{type}}</param>
29+
{{/vendorExtensions.x-param-groups}}
2730
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
2831
/// <returns>Task of {{returnType}}{{^returnType}}void{{/returnType}}</returns>
2932
{{#isDeprecated}}
3033
[Obsolete]
3134
{{/isDeprecated}}
32-
{{#returnType}}Task<{{{.}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default);
35+
{{#returnType}}Task<{{{.}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{operationId}}Async({{#allParams}}{{^vendorExtensions.x-param-group-camel}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}, {{/vendorExtensions.x-param-group-camel}}{{/allParams}}{{#vendorExtensions.x-param-groups}}{{type}} {{camel}} = default, {{/vendorExtensions.x-param-groups}}System.Threading.CancellationToken cancellationToken = default);
3336
{{/operation}}
3437
}
3538
{{/operations}}
File renamed without changes.

codegen/Templates/dart/api.mustache

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class {{classname}} {
2222
{{#isDeprecated}}
2323
@deprecated
2424
{{/isDeprecated}}
25-
{{#returnType}}Future<{{#isResponseFile}}Uint8List{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}({{#allParams}}{{#required}}{{^isFile}}{{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}Uint8List {{paramName}}Bytes{{/isFile}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{^isFile}}{{{dataType}}}? {{paramName}}{{/isFile}}{{#isFile}}Uint8List? {{paramName}}Bytes{{/isFile}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
25+
{{#returnType}}Future<{{#isResponseFile}}Uint8List{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}({{#allParams}}{{#required}}{{^isFile}}{{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}Uint8List {{paramName}}Bytes{{/isFile}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{^vendorExtensions.x-param-group-camel}}{{^isFile}}{{{dataType}}}? {{paramName}}{{/isFile}}{{#isFile}}Uint8List? {{paramName}}Bytes{{/isFile}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-param-group-camel}}{{/required}}{{/allParams}}{{#vendorExtensions.x-param-groups}}{{type}}? {{camel}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-param-groups}} }{{/hasOptionalParams}}) async {
2626
// ignore: prefer_final_locals
2727
Object? postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
2828

@@ -34,13 +34,20 @@ class {{classname}} {
3434
final Map<String, String> headerParams = {};
3535
final Map<String, String> formParams = {};
3636
{{#queryParams}}
37+
{{^vendorExtensions.x-param-group-camel}}
3738
{{^required}}
3839
if({{paramName}} != null) {
3940
{{/required}}
4041
queryParams.addAll(convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
4142
{{^required}}
4243
}
4344
{{/required}}
45+
{{/vendorExtensions.x-param-group-camel}}
46+
{{#vendorExtensions.x-param-group-camel}}
47+
if({{vendorExtensions.x-param-group-camel}}?.{{paramName}} != null) {
48+
queryParams.addAll(convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{vendorExtensions.x-param-group-camel}}!.{{paramName}}));
49+
}
50+
{{/vendorExtensions.x-param-group-camel}}
4451
{{/queryParams}}
4552
{{#headerParams}}headerParams["{{baseName}}"] = {{paramName}};
4653
{{/headerParams}}
@@ -52,7 +59,9 @@ class {{classname}} {
5259

5360
{{#hasFormParams}}
5461
MultipartRequestPlus mp = MultipartRequestPlus('{{httpMethod}}', Uri.parse(requestPath));
55-
{{#formParams}}{{^isFile}}
62+
{{#formParams}}
63+
{{^vendorExtensions.x-param-group-camel}}
64+
{{^isFile}}
5665
if ({{paramName}} != null) {
5766
{{#isCollectionFormatMulti}}
5867
final List<String> stringValues = {{paramName}}.map((i) => parameterToString(i)).toList();
@@ -62,8 +71,8 @@ class {{classname}} {
6271
mp.fields['{{baseName}}'] = [parameterToString({{paramName}})];
6372
{{/isCollectionFormatMulti}}
6473
}
65-
{{/isFile}}{{#isFile}}
66-
74+
{{/isFile}}
75+
{{#isFile}}
6776
{{#required}}
6877
mp.files.add(MultipartFile.fromBytes("{{paramName}}", {{paramName}}Bytes.toList(), filename: "somefile.xyz"));
6978
{{/required}}
@@ -72,10 +81,16 @@ class {{classname}} {
7281
mp.files.add(MultipartFile.fromBytes("{{paramName}}", {{paramName}}Bytes.toList(), filename: "somefile.xyz"));
7382
}
7483
{{/required}}
75-
76-
{{/isFile}}{{/formParams}}
84+
{{/isFile}}
85+
{{/vendorExtensions.x-param-group-camel}}
86+
{{#vendorExtensions.x-param-group-camel}}
87+
if ({{vendorExtensions.x-param-group-camel}}?.{{paramName}} != null) {
88+
mp.fields['{{baseName}}'] = [parameterToString({{vendorExtensions.x-param-group-camel}}!.{{paramName}})];
89+
}
90+
{{/vendorExtensions.x-param-group-camel}}
91+
{{/formParams}}
7792
postBody = mp;
78-
93+
7994
{{/hasFormParams}}
8095

8196
final response = await _apiClient.invokeAPI(requestPath,

0 commit comments

Comments
 (0)