Skip to content

Commit 72c3f5a

Browse files
committed
Merge branch 'release/common-1.0.0' into main
2 parents 45e2e83 + deef976 commit 72c3f5a

File tree

6 files changed

+128
-26
lines changed

6 files changed

+128
-26
lines changed

.github/workflows/release-all.yaml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Build, test, package and release
1111
strategy:
1212
matrix:
13-
os: [ 'windows-latest', 'ubuntu-latest', 'macos-latest' ]
13+
os: [ 'windows-latest' ]
1414

1515
runs-on: ${{ matrix.os }}
1616

@@ -29,20 +29,14 @@ jobs:
2929
$module = $segments[0]
3030
$version = $segments[1]
3131
32-
# echo "::set-env name=RELEASE_MODULE::$module"
33-
# echo "::set-env name=RELEASE_VERSION::$version"
34-
3532
echo "::set-output name=module::$module"
3633
echo "::set-output name=version::$version"
3734
3835
- name: Check release module and version
3936
shell: pwsh
4037
run: |
41-
# echo "env: $env:RELEASE_MODULE"
42-
# echo "env: $env:RELEASE_VERSION"
43-
44-
echo "output: ${{ steps.release.outputs.module }}"
45-
echo "output: ${{ steps.release.outputs.version }}"
38+
echo "module: ${{ steps.release.outputs.module }}"
39+
echo "version: ${{ steps.release.outputs.version }}"
4640
4741
- name: Checkout the repository
4842
uses: actions/checkout@v2
@@ -78,24 +72,21 @@ jobs:
7872
7973
- name: List Package for Common
8074
if: steps.release.outputs.module == 'common'
75+
id: package
8176
shell: pwsh
8277
run: |
8378
$package = Get-ChildItem -Path ./src/*.Common -Include *.nupkg -Recurse | Where-Object { $_.FullName -like "*${{ steps.release.outputs.version }}*" }
8479
$path = $package[0].FullName
8580
$name = $package[0].Name
8681
87-
echo "::set-env name=PACKAGE_PATH::$path"
88-
echo "::set-env name=PACKAGE_NAME::$name"
82+
echo "::set-output name=path::$path"
83+
echo "::set-output name=name::$name"
8984
9085
- name: Check package path and name
91-
id: package
9286
shell: pwsh
9387
run: |
94-
echo "package-path: $env:PACKAGE_PATH"
95-
echo "package-name: $env:PACKAGE_NAME"
96-
97-
echo "::set-output name=path::$env:PACKAGE_PATH"
98-
echo "::set-output name=name::$env:PACKAGE_NAME"
88+
echo "path: ${{ steps.package.outputs.path }}"
89+
echo "name: ${{ steps.package.outputs.name }}"
9990
10091
- name: Create Release to GitHub
10192
id: ghrelease

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,23 @@ This provides some useful extensions for Azure Functions.
1010

1111
## Getting Started ![Build and Test](https://github.com/aliencube/AzureFunctions.Extensions/workflows/Build%20and%20Test/badge.svg) ##
1212

13+
| Package | Status | Version |
14+
| --- | --- | --- |
15+
| [Aliencube.AzureFunctions.Extensions.Common](./docs/common.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.Common.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Common/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.Common.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Common/) |
16+
17+
18+
### Packages for Reference Only ###
19+
1320
The following extensions are not actively developed any longer, but for reference only. You can find out the archived source codes by checking out the [archived](https://github.com/aliencube/AzureFunctions.Extensions/tree/archived) tag.
1421

1522
| Package | Status | Version |
1623
| --- | --- | --- |
17-
| [Aliencube.AzureFunctions.Extensions.Configuration.AppSettings](./docs/app-settings.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings/) |
18-
| [Aliencube.AzureFunctions.Extensions.Configuration.Json](./docs/configuration-json.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.Configuration.Json.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.Json/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.Configuration.Json.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.Json/) |
19-
| [Aliencube.AzureFunctions.Extensions.DependencyInjection](./docs/dependency-injection.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.DependencyInjection.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.DependencyInjection/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.DependencyInjection.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.DependencyInjection/) |
20-
| [Aliencube.AzureFunctions.Extensions.OpenApi.Core](./docs/openapi-core.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.OpenApi.Core.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi.Core/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.OpenApi.Core.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi.Core/) |
21-
| [Aliencube.AzureFunctions.Extensions.OpenApi](./docs/openapi.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.OpenApi.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.OpenApi.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi/) |
22-
| [Aliencube.AzureFunctions.Extensions.OpenApi.CLI](./docs/openapi-cli.md) | [![](https://img.shields.io/static/v1?label=tag&message=cli-*&color=brightgreen)](https://github.com/aliencube/AzureFunctions.Extensions/releases) | [![](https://img.shields.io/static/v1?label=tag&message=cli-*&color=brightgreen)](https://github.com/aliencube/AzureFunctions.Extensions/releases) |
24+
| [Aliencube.AzureFunctions.Extensions.Configuration.AppSettings](../archived/docs/app-settings.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.AppSettings/) |
25+
| [Aliencube.AzureFunctions.Extensions.Configuration.Json](../archived/docs/configuration-json.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.Configuration.Json.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.Json/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.Configuration.Json.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.Configuration.Json/) |
26+
| [Aliencube.AzureFunctions.Extensions.DependencyInjection](../archived/docs/dependency-injection.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.DependencyInjection.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.DependencyInjection/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.DependencyInjection.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.DependencyInjection/) |
27+
| [Aliencube.AzureFunctions.Extensions.OpenApi.Core](../archived/docs/openapi-core.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.OpenApi.Core.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi.Core/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.OpenApi.Core.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi.Core/) |
28+
| [Aliencube.AzureFunctions.Extensions.OpenApi](../archived/docs/openapi.md) | [![](https://img.shields.io/nuget/dt/Aliencube.AzureFunctions.Extensions.OpenApi.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi/) | [![](https://img.shields.io/nuget/v/Aliencube.AzureFunctions.Extensions.OpenApi.svg)](https://www.nuget.org/packages/Aliencube.AzureFunctions.Extensions.OpenApi/) |
29+
| [Aliencube.AzureFunctions.Extensions.OpenApi.CLI](../archived/docs/openapi-cli.md) | [![](https://img.shields.io/static/v1?label=tag&message=cli-*&color=brightgreen)](https://github.com/aliencube/AzureFunctions.Extensions/releases) | [![](https://img.shields.io/static/v1?label=tag&message=cli-*&color=brightgreen)](https://github.com/aliencube/AzureFunctions.Extensions/releases) |
2330

2431

2532
## Acknowledgement ##

docs/common.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Aliencube.AzureFunctions.Extensions.Common #
2+
3+
This extension provides constants and extension methods frequently used while developing Azure Functions apps.
4+
5+
6+
## Constants ##
7+
8+
The following constants represent the string respectively.
9+
10+
11+
### `ContentTypes` ###
12+
13+
It specifies the content type.
14+
15+
* `ContentTypes.PlainText`: `text/plain`
16+
* `ContentTypes.TextHtml`: `text/html`
17+
* `ContentTypes.ApplicationJson`: `application/json`
18+
* `ContentTypes.TextVndYaml`: `text/vnd.yaml`
19+
20+
21+
### `HttpVerbs` ###
22+
23+
It specifies the HTTP method.
24+
25+
* `HttpVerbs.GET`: `GET`
26+
* `HttpVerbs.POST`: `POST`
27+
* `HttpVerbs.PUT`: `PUT`
28+
* `HttpVerbs.PATCH`: `PATCH`
29+
* `HttpVerbs.DELETE`: `DELETE`
30+
31+
32+
## Enums ##
33+
34+
### `SourceFrom` ###
35+
36+
It specifies whether the HTTP request comes from.
37+
38+
* `Header`: Request source comes from the request header.
39+
* `Query`: Request source comes from the request querystring.
40+
* `Body`: Request source comes from the request body.
41+
42+
43+
## Extension Methods ##
44+
45+
### `HttpRequestExtensions.To<T>(SourceFrom source)` ###
46+
47+
It extracts relevant data from the given source of the HTTP request.
48+
49+
```csharp
50+
public async Task<IActionResult> Run(
51+
[HttpTrigger(AuthorizationLevel.Anonymous, HttpVerbs.GET)] HttpRequest req)
52+
{
53+
var headers = await req.To<IHeaderDictionary>(SourceFrom.Header)
54+
.ConfigureAwait(false);
55+
56+
var queries = await req.To<IQueryCollection>(SourceFrom.Query)
57+
.ConfigureAwait(false);
58+
59+
var payload = await req.To<MyClass>(SourceFrom.Body)
60+
.ConfigureAwait(false);
61+
...
62+
}
63+
```
64+
65+
66+
### `OpenApiFormatExtensions.GetContentType()` ###
67+
68+
It returns the content type based on the OpenAPI document format.
69+
70+
```csharp
71+
var format = OpenApiFormat.Json;
72+
var contentType = format.GetContentType();
73+
```
74+
75+
76+
### `PayloadExtensions.ToJson<T>()` ###
77+
78+
It serialises the given payload to JSON string.
79+
80+
```csharp
81+
var payload = new MyClass() { Message = "hello world" };
82+
var serialised = payload.ToJson();
83+
```
84+
85+
86+
### `PayloadExtensions.FromJson<T>()` ###
87+
88+
It deserialises the JSON string value to given type.
89+
90+
```csharp
91+
var payload = "{ \"message\": \"hello world\" }"
92+
var deserialised = payload.FromJson<MyClass>(payload);
93+
```
595 Bytes
Loading

release-notes/common-1.0.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Release Note: `Aliencube.AzureFunctions.Extensions.Common` &ndash; `1.0.0` #
2+
3+
Initial release
4+

src/Aliencube.AzureFunctions.Extensions.Common/PayloadExtensions.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ namespace Aliencube.AzureFunctions.Extensions.Common
88
public static class PayloadExtensions
99
{
1010
/// <summary>
11-
/// Replaces the placeholder with the given value.
11+
/// Serialises the given payload to JSON string.
1212
/// </summary>
13-
/// <param name="payload"><see cref="PlaceholderReplaceRequest"/> instance.</param>
14-
/// <returns>Returns the replaced value.</returns>
13+
/// <typeparam name="T">Type of the payload to serialise.</typeparam>
14+
/// <param name="payload">Payload object.</param>
15+
/// <returns>Returns the serialised JSON string value.</returns>
1516
public static string ToJson<T>(this T payload)
1617
{
1718
if (payload == null)
@@ -24,6 +25,12 @@ public static string ToJson<T>(this T payload)
2425
return result;
2526
}
2627

28+
/// <summary>
29+
/// Deserialises the JSON string value to given type.
30+
/// </summary>
31+
/// <typeparam name="T">Type of the payload to deserialise.</typeparam>
32+
/// <param name="payload">JSON string value.</param>
33+
/// <returns>Returns the deserialised object.</returns>
2734
public static T FromJson<T>(this string payload)
2835
{
2936
if (string.IsNullOrWhiteSpace(payload))

0 commit comments

Comments
 (0)