Skip to content

Commit 55a5c0f

Browse files
authored
Release 25.1 V4 (#101)
* Generated with v4.0 swagger spec Generate with openapi generator Added tests Fixed formating Fixed binary api invocation Added checking for non required enums Changed examples Fixed default Configuration Fixed tests Fixed api exception message when not format error response All post form are multipart Regenerated after spec update Test fix Added some snippets for documentation pages Added set target types snippets Base64 encode refactoring Added snippets for read pages Added generate snippets for doc Added manual fetch token snippet Add csproj file snippet for documentation Switch to common credentials template Added scripts for snippets tests. Snippets fixed Regenerated after added new operationId to spec. Refactoring - deleted intermediate request models Tests fixed Snippets fixed Code formated Fixed warnings * Copyright year updated * Fixed tests * Added snippets test to ci * JWT_TOKEN to ACCESS_TOKEN * Fixes * Rename JWT_TOKEN to ACCESS_TOKEN * README updated
1 parent cf882eb commit 55a5c0f

File tree

278 files changed

+4315
-11099
lines changed

Some content is hidden

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

278 files changed

+4315
-11099
lines changed

.github/workflows/net-framework.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: |
4242
$ErrorActionPreference = "Stop"
4343
VSTest.Console.exe /Framework:".NETFramework,Version=${{ matrix.net-version }}" /ResultsDirectory:Tests\Results /Logger:"trx;LogFileName=test.log" Tests\bin\Release\${{ matrix.framework }}\Aspose.BarCode.Cloud.Sdk.Tests.dll
44-
if( ([xml](Get-Content Tests\Results\test.log)).TestRun.ResultSummary.Counters.total -ne 29 ){ throw "Not all tests were explored or added new tests" }
44+
if( ([xml](Get-Content Tests\Results\test.log)).TestRun.ResultSummary.Counters.total -ne 25 ){ throw "Not all tests were explored or added new tests" }
4545
4646
env:
4747
TEST_CONFIGURATION_JWT_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}

.github/workflows/build-examples.yml renamed to .github/workflows/test-examples-and-snippets.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build examples
1+
name: Build examples and run snippets
22

33
on:
44
push:
@@ -15,6 +15,14 @@ jobs:
1515
- name: Setup latest version of dotnet
1616
uses: actions/setup-dotnet@v4
1717
- name: Build nuget with latest version
18-
run: ./scripts/pack-nuget.bash "examples/nuget-packages"
18+
run: |
19+
./scripts/pack-nuget.bash
20+
cp *.nupkg examples/nuget-packages
1921
- name: Build examples with new nuget
2022
run: dotnet build --warnaserror "examples/examples.sln"
23+
- name: Run documentation code snippets
24+
run: |
25+
chmod +x scripts/*
26+
./scripts/run_snippets.sh
27+
env:
28+
TEST_CONFIGURATION_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ obj
77
Tests/Configuration*.json
88
*.DotSettings
99
*.binlog
10+
snippets_test/
11+
*.nupkg

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ init:
1111
format:
1212
dotnet restore ./Aspose.BarCode.Cloud.Sdk.sln
1313
dotnet format ./Aspose.BarCode.Cloud.Sdk.sln --no-restore
14+
dotnet format --include ./snippets/
1415
# Trim white space in comments
1516
find . -iname "*.cs" -exec sed -i -e 's_[[:space:]]*$$__' {} \;
1617

18+
1719
.PHONY: format-doc
1820
format-doc:
1921
# Remove trailing white space
@@ -22,6 +24,7 @@ format-doc:
2224
.PHONY: test
2325
test:
2426
dotnet test -v normal --framework=net$(LATEST_SDK_VERSION)
27+
./scripts/run_snippests.sh
2528

2629
.PHONY: build
2730
build:

README.md

+46-114
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
[![.NET Framework Windows](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/net-framework.yml/badge.svg?branch=main)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/net-framework.yml)
66
[![Nuget](https://img.shields.io/nuget/v/Aspose.BarCode-Cloud)](https://www.nuget.org/packages/Aspose.BarCode-Cloud/)
77

8-
- API version: 3.0
9-
- SDK version: 24.12.0
8+
- API version: 4.0
9+
- SDK version: 25.1.0
10+
11+
## SDK and API Version Compatibility:
12+
13+
- SDK Version 25.1 and Later: Starting from SDK version 25.1, all subsequent versions are compatible with API Version v4.0.
14+
- SDK Version 24.12 and Earlier: These versions are compatible with API Version v3.0.
1015

1116
## Demo applications
1217

@@ -67,7 +72,7 @@ The examples below show how you can recognize QR code from image:
6772
using Aspose.BarCode.Cloud.Sdk.Api;
6873
using Aspose.BarCode.Cloud.Sdk.Interfaces;
6974
using Aspose.BarCode.Cloud.Sdk.Model;
70-
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
75+
7176
using System;
7277
using System.Collections.Generic;
7378
using System.IO;
@@ -96,13 +101,16 @@ internal static class Program
96101
return config;
97102
}
98103

99-
private static async Task<string> ReadQR(IBarcodeApi api, string fileName)
104+
private static async Task<string> ReadQR(IRecognizeApi api, string fileName)
100105
{
101-
await using FileStream imageStream = File.OpenRead(fileName);
102-
BarcodeResponseList recognized = await api.ScanBarcodeAsync(
103-
new ScanBarcodeRequest(imageStream)
106+
byte[] imageBytes = await File.ReadAllBytesAsync(fileName);
107+
string imageBase64 = Convert.ToBase64String(imageBytes);
108+
109+
BarcodeResponseList recognized = await api.RecognizeBase64Async(
110+
new RecognizeBase64Request()
104111
{
105-
decodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.QR }
112+
BarcodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.QR },
113+
FileBase64 = imageBase64
106114
}
107115
);
108116

@@ -117,7 +125,7 @@ internal static class Program
117125
"qr.png"
118126
));
119127

120-
var api = new BarcodeApi(MakeConfiguration());
128+
var api = new RecognizeApi(MakeConfiguration());
121129

122130
string result = await ReadQR(api, fileName);
123131
Console.WriteLine($"File '{fileName}' recognized, result: '{result}'");
@@ -134,7 +142,7 @@ The examples below show how you can generate QR code and save it into local file
134142
using Aspose.BarCode.Cloud.Sdk.Api;
135143
using Aspose.BarCode.Cloud.Sdk.Interfaces;
136144
using Aspose.BarCode.Cloud.Sdk.Model;
137-
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
145+
138146
using System;
139147
using System.IO;
140148
using System.Reflection;
@@ -162,16 +170,14 @@ internal static class Program
162170
return config;
163171
}
164172

165-
private static async Task GenerateQR(IBarcodeApi api, string fileName)
173+
private static async Task GenerateQR(IGenerateApi api, string fileName)
166174
{
167-
await using Stream generated = await api.GetBarcodeGenerateAsync(
168-
new GetBarcodeGenerateRequest(
169-
EncodeBarcodeType.QR.ToString(),
170-
"QR code text")
171-
{
172-
TextLocation = CodeLocation.None.ToString(),
173-
format = "png"
174-
});
175+
await using Stream generated = await api.GenerateAsync(
176+
EncodeBarcodeType.QR,
177+
"QR code text",
178+
textLocation: CodeLocation.None,
179+
imageFormat: BarcodeImageFormat.Png
180+
);
175181
await using FileStream stream = File.Create(fileName);
176182
await generated.CopyToAsync(stream);
177183
}
@@ -184,7 +190,7 @@ internal static class Program
184190
"qr.png"
185191
));
186192

187-
BarcodeApi api = new BarcodeApi(MakeConfiguration());
193+
GenerateApi api = new GenerateApi(MakeConfiguration());
188194

189195
await GenerateQR(api, fileName);
190196
Console.WriteLine($"File '{fileName}' generated.");
@@ -212,112 +218,38 @@ All Aspose.BarCode for Cloud SDKs, helper scripts and templates are licensed und
212218

213219
## Documentation for API Endpoints
214220

215-
All URIs are relative to *<https://api.aspose.cloud/v3.0>*
221+
All URIs are relative to *<https://api.aspose.cloud/v4.0>*
216222

217223
Class | Method | HTTP request | Description
218224
----- | ------ | ------------ | -----------
219-
*BarcodeApi* | [**GetBarcodeGenerate**](docs/BarcodeApi.md#getbarcodegenerate) | **GET** /barcode/generate | Generate barcode.
220-
*BarcodeApi* | [**GetBarcodeRecognize**](docs/BarcodeApi.md#getbarcoderecognize) | **GET** /barcode/{name}/recognize | Recognize barcode from a file on server.
221-
*BarcodeApi* | [**PostBarcodeRecognizeFromUrlOrContent**](docs/BarcodeApi.md#postbarcoderecognizefromurlorcontent) | **POST** /barcode/recognize | Recognize barcode from an url or from request body. Request body can contain raw data bytes of the image with content-type \"application/octet-stream\". An image can also be passed as a form field.
222-
*BarcodeApi* | [**PostGenerateMultiple**](docs/BarcodeApi.md#postgeneratemultiple) | **POST** /barcode/generateMultiple | Generate multiple barcodes and return in response stream
223-
*BarcodeApi* | [**PutBarcodeGenerateFile**](docs/BarcodeApi.md#putbarcodegeneratefile) | **PUT** /barcode/{name}/generate | Generate barcode and save on server (from query params or from file with json or xml content)
224-
*BarcodeApi* | [**PutBarcodeRecognizeFromBody**](docs/BarcodeApi.md#putbarcoderecognizefrombody) | **PUT** /barcode/{name}/recognize | Recognition of a barcode from file on server with parameters in body.
225-
*BarcodeApi* | [**PutGenerateMultiple**](docs/BarcodeApi.md#putgeneratemultiple) | **PUT** /barcode/{name}/generateMultiple | Generate image with multiple barcodes and put new file on server
226-
*BarcodeApi* | [**ScanBarcode**](docs/BarcodeApi.md#scanbarcode) | **POST** /barcode/scan | Quickly scan a barcode from an image.
227-
*FileApi* | [**CopyFile**](docs/FileApi.md#copyfile) | **PUT** /barcode/storage/file/copy/{srcPath} | Copy file
228-
*FileApi* | [**DeleteFile**](docs/FileApi.md#deletefile) | **DELETE** /barcode/storage/file/{path} | Delete file
229-
*FileApi* | [**DownloadFile**](docs/FileApi.md#downloadfile) | **GET** /barcode/storage/file/{path} | Download file
230-
*FileApi* | [**MoveFile**](docs/FileApi.md#movefile) | **PUT** /barcode/storage/file/move/{srcPath} | Move file
231-
*FileApi* | [**UploadFile**](docs/FileApi.md#uploadfile) | **PUT** /barcode/storage/file/{path} | Upload file
232-
*FolderApi* | [**CopyFolder**](docs/FolderApi.md#copyfolder) | **PUT** /barcode/storage/folder/copy/{srcPath} | Copy folder
233-
*FolderApi* | [**CreateFolder**](docs/FolderApi.md#createfolder) | **PUT** /barcode/storage/folder/{path} | Create the folder
234-
*FolderApi* | [**DeleteFolder**](docs/FolderApi.md#deletefolder) | **DELETE** /barcode/storage/folder/{path} | Delete folder
235-
*FolderApi* | [**GetFilesList**](docs/FolderApi.md#getfileslist) | **GET** /barcode/storage/folder/{path} | Get all files and folders within a folder
236-
*FolderApi* | [**MoveFolder**](docs/FolderApi.md#movefolder) | **PUT** /barcode/storage/folder/move/{srcPath} | Move folder
237-
*StorageApi* | [**GetDiscUsage**](docs/StorageApi.md#getdiscusage) | **GET** /barcode/storage/disc | Get disc usage
238-
*StorageApi* | [**GetFileVersions**](docs/StorageApi.md#getfileversions) | **GET** /barcode/storage/version/{path} | Get file versions
239-
*StorageApi* | [**ObjectExists**](docs/StorageApi.md#objectexists) | **GET** /barcode/storage/exist/{path} | Check if file or folder exists
240-
*StorageApi* | [**StorageExists**](docs/StorageApi.md#storageexists) | **GET** /barcode/storage/{storageName}/exist | Check if storage exists
225+
*GenerateApi* | [**Generate**](docs/GenerateApi.md#generate) | **GET** /barcode/generate/{barcodeType} | Generate barcode using GET request with parameters in route and query string.
226+
*GenerateApi* | [**GenerateBody**](docs/GenerateApi.md#generatebody) | **POST** /barcode/generate-body | Generate barcode using POST request with parameters in body in json or xml format.
227+
*GenerateApi* | [**GenerateMultipart**](docs/GenerateApi.md#generatemultipart) | **POST** /barcode/generate-multipart | Generate barcode using POST request with parameters in multipart form.
228+
*RecognizeApi* | [**Recognize**](docs/RecognizeApi.md#recognize) | **GET** /barcode/recognize | Recognize barcode from file on server using GET requests with parameters in route and query string.
229+
*RecognizeApi* | [**RecognizeBase64**](docs/RecognizeApi.md#recognizebase64) | **POST** /barcode/recognize-body | Recognize barcode from file in request body using POST requests with parameters in body in json or xml format.
230+
*RecognizeApi* | [**RecognizeMultipart**](docs/RecognizeApi.md#recognizemultipart) | **POST** /barcode/recognize-multipart | Recognize barcode from file in request body using POST requests with parameters in multipart form.
231+
*ScanApi* | [**Scan**](docs/ScanApi.md#scan) | **GET** /barcode/scan | Scan barcode from file on server using GET requests with parameter in query string.
232+
*ScanApi* | [**ScanBase64**](docs/ScanApi.md#scanbase64) | **POST** /barcode/scan-body | Scan barcode from file in request body using POST requests with parameter in body in json or xml format.
233+
*ScanApi* | [**ScanMultipart**](docs/ScanApi.md#scanmultipart) | **POST** /barcode/scan-multipart | Scan barcode from file in request body using POST requests with parameter in multipart form.
241234

242235
## Documentation for Models
243236

244237
- [Model.ApiError](docs/ApiError.md)
245238
- [Model.ApiErrorResponse](docs/ApiErrorResponse.md)
246-
- [Model.AustralianPostParams](docs/AustralianPostParams.md)
247-
- [Model.AutoSizeMode](docs/AutoSizeMode.md)
248-
- [Model.AvailableGraphicsUnit](docs/AvailableGraphicsUnit.md)
249-
- [Model.AztecEncodeMode](docs/AztecEncodeMode.md)
250-
- [Model.AztecParams](docs/AztecParams.md)
251-
- [Model.AztecSymbolMode](docs/AztecSymbolMode.md)
239+
- [Model.BarcodeImageFormat](docs/BarcodeImageFormat.md)
240+
- [Model.BarcodeImageParams](docs/BarcodeImageParams.md)
252241
- [Model.BarcodeResponse](docs/BarcodeResponse.md)
253242
- [Model.BarcodeResponseList](docs/BarcodeResponseList.md)
254-
- [Model.BorderDashStyle](docs/BorderDashStyle.md)
255-
- [Model.CaptionParams](docs/CaptionParams.md)
256-
- [Model.ChecksumValidation](docs/ChecksumValidation.md)
257-
- [Model.CodabarChecksumMode](docs/CodabarChecksumMode.md)
258-
- [Model.CodabarParams](docs/CodabarParams.md)
259-
- [Model.CodabarSymbol](docs/CodabarSymbol.md)
260-
- [Model.CodablockParams](docs/CodablockParams.md)
261-
- [Model.Code128Emulation](docs/Code128Emulation.md)
262-
- [Model.Code128EncodeMode](docs/Code128EncodeMode.md)
263-
- [Model.Code128Params](docs/Code128Params.md)
264-
- [Model.Code16KParams](docs/Code16KParams.md)
265243
- [Model.CodeLocation](docs/CodeLocation.md)
266-
- [Model.CouponParams](docs/CouponParams.md)
267-
- [Model.CustomerInformationInterpretingType](docs/CustomerInformationInterpretingType.md)
268-
- [Model.DataBarParams](docs/DataBarParams.md)
269-
- [Model.DataMatrixEccType](docs/DataMatrixEccType.md)
270-
- [Model.DataMatrixEncodeMode](docs/DataMatrixEncodeMode.md)
271-
- [Model.DataMatrixParams](docs/DataMatrixParams.md)
272-
- [Model.DataMatrixVersion](docs/DataMatrixVersion.md)
273244
- [Model.DecodeBarcodeType](docs/DecodeBarcodeType.md)
274-
- [Model.DiscUsage](docs/DiscUsage.md)
275-
- [Model.DotCodeEncodeMode](docs/DotCodeEncodeMode.md)
276-
- [Model.DotCodeParams](docs/DotCodeParams.md)
277-
- [Model.ECIEncodings](docs/ECIEncodings.md)
278-
- [Model.EnableChecksum](docs/EnableChecksum.md)
279245
- [Model.EncodeBarcodeType](docs/EncodeBarcodeType.md)
280-
- [Model.Error](docs/Error.md)
281-
- [Model.ErrorDetails](docs/ErrorDetails.md)
282-
- [Model.FileVersions](docs/FileVersions.md)
283-
- [Model.FilesList](docs/FilesList.md)
284-
- [Model.FilesUploadResult](docs/FilesUploadResult.md)
285-
- [Model.FontMode](docs/FontMode.md)
286-
- [Model.FontParams](docs/FontParams.md)
287-
- [Model.FontStyle](docs/FontStyle.md)
288-
- [Model.GeneratorParams](docs/GeneratorParams.md)
289-
- [Model.GeneratorParamsList](docs/GeneratorParamsList.md)
290-
- [Model.HanXinEncodeMode](docs/HanXinEncodeMode.md)
291-
- [Model.HanXinErrorLevel](docs/HanXinErrorLevel.md)
292-
- [Model.HanXinParams](docs/HanXinParams.md)
293-
- [Model.HanXinVersion](docs/HanXinVersion.md)
294-
- [Model.ITF14BorderType](docs/ITF14BorderType.md)
295-
- [Model.ITFParams](docs/ITFParams.md)
296-
- [Model.MacroCharacter](docs/MacroCharacter.md)
297-
- [Model.MaxiCodeEncodeMode](docs/MaxiCodeEncodeMode.md)
298-
- [Model.MaxiCodeMode](docs/MaxiCodeMode.md)
299-
- [Model.MaxiCodeParams](docs/MaxiCodeParams.md)
300-
- [Model.ObjectExist](docs/ObjectExist.md)
301-
- [Model.Padding](docs/Padding.md)
302-
- [Model.PatchCodeParams](docs/PatchCodeParams.md)
303-
- [Model.PatchFormat](docs/PatchFormat.md)
304-
- [Model.Pdf417CompactionMode](docs/Pdf417CompactionMode.md)
305-
- [Model.Pdf417ErrorLevel](docs/Pdf417ErrorLevel.md)
306-
- [Model.Pdf417MacroTerminator](docs/Pdf417MacroTerminator.md)
307-
- [Model.Pdf417Params](docs/Pdf417Params.md)
308-
- [Model.PostalParams](docs/PostalParams.md)
309-
- [Model.PresetType](docs/PresetType.md)
310-
- [Model.QREncodeMode](docs/QREncodeMode.md)
311-
- [Model.QREncodeType](docs/QREncodeType.md)
312-
- [Model.QRErrorLevel](docs/QRErrorLevel.md)
313-
- [Model.QRVersion](docs/QRVersion.md)
314-
- [Model.QrParams](docs/QrParams.md)
315-
- [Model.ReaderParams](docs/ReaderParams.md)
246+
- [Model.EncodeData](docs/EncodeData.md)
247+
- [Model.EncodeDataType](docs/EncodeDataType.md)
248+
- [Model.GenerateParams](docs/GenerateParams.md)
249+
- [Model.GraphicsUnit](docs/GraphicsUnit.md)
250+
- [Model.RecognitionImageKind](docs/RecognitionImageKind.md)
251+
- [Model.RecognitionMode](docs/RecognitionMode.md)
252+
- [Model.RecognizeBase64Request](docs/RecognizeBase64Request.md)
316253
- [Model.RegionPoint](docs/RegionPoint.md)
317-
- [Model.ResultImageInfo](docs/ResultImageInfo.md)
318-
- [Model.StorageExist](docs/StorageExist.md)
319-
- [Model.StorageFile](docs/StorageFile.md)
320-
- [Model.StructuredAppend](docs/StructuredAppend.md)
321-
- [Model.TextAlignment](docs/TextAlignment.md)
322-
- [Model.FileVersion](docs/FileVersion.md)
254+
- [Model.ScanBase64Request](docs/ScanBase64Request.md)
323255

Tests/ApiExceptionTests.cs

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Aspose.BarCode.Cloud.Sdk.Api;
22
using Aspose.BarCode.Cloud.Sdk.Model;
3-
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
3+
44
using NUnit.Framework;
55

66
namespace Aspose.BarCode.Cloud.Sdk.Tests
@@ -14,21 +14,18 @@ public class ApiExceptionTests : TestsBase
1414
public void GetBarcodeGenerateAsyncTestThrows()
1515
{
1616
// Arrange
17-
var api = new BarcodeApi(clientId: "client id", clientSecret: "client secret");
18-
var request = new GetBarcodeGenerateRequest(
19-
text: "Very sample text",
20-
type: EncodeBarcodeType.Code128.ToString()
21-
)
22-
{
23-
format = "png"
24-
};
17+
GenerateApi api = new GenerateApi(clientId: "client id", clientSecret: "client secret");
2518

2619
// Acts
27-
var ex = Assert.ThrowsAsync<ApiException>(
28-
async () => { await api.GetBarcodeGenerateAsync(request); });
20+
ApiException ex = Assert.ThrowsAsync<ApiException>(
21+
async () =>
22+
{
23+
await api.GenerateAsync(data: "Very sample text",
24+
barcodeType: EncodeBarcodeType.Code128, imageFormat: BarcodeImageFormat.Png);
25+
});
2926

3027
Assert.AreEqual(400, ex!.ErrorCode);
31-
Assert.AreEqual("Bad Request", ex.Message);
28+
Assert.AreEqual("{\"error\":\"invalid_client\"}: ", ex.Message);
3229
}
3330
}
3431
}

0 commit comments

Comments
 (0)