ParameterStyleParsers.OpenAPI 1.0.0-pre-fc3e8a7a

This is a prerelease version of ParameterStyleParsers.OpenAPI.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ParameterStyleParsers.OpenAPI --version 1.0.0-pre-fc3e8a7a
NuGet\Install-Package ParameterStyleParsers.OpenAPI -Version 1.0.0-pre-fc3e8a7a
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ParameterStyleParsers.OpenAPI" Version="1.0.0-pre-fc3e8a7a" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ParameterStyleParsers.OpenAPI --version 1.0.0-pre-fc3e8a7a
#r "nuget: ParameterStyleParsers.OpenAPI, 1.0.0-pre-fc3e8a7a"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ParameterStyleParsers.OpenAPI as a Cake Addin
#addin nuget:?package=ParameterStyleParsers.OpenAPI&version=1.0.0-pre-fc3e8a7a&prerelease

// Install ParameterStyleParsers.OpenAPI as a Cake Tool
#tool nuget:?package=ParameterStyleParsers.OpenAPI&version=1.0.0-pre-fc3e8a7a&prerelease

OpenAPI.ParameterStyleParsers

Parameter style parsers for OpenAPI 3.1.

The examples in the OpenAPI specification doesn't match RFC6570 fully, in those cases the examples in the specification are followed.

Continuous Delivery

Installation

dotnet add package ParameterStyleParsers.OpenAPI

https://www.nuget.org/packages/ParameterStyleParsers.OpenAPI/

Getting Started

Create the parser by providing the OpenAPI 3.1 parameter specification.

var parser = OpenAPI.ParameterStyleParsers.ParameterParsers.ParameterValueParser.FromOpenApi31ParameterSpecification(
    JsonNode.Parse("""
    {
        "name": "color",
        "in": "query",
        "schema": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "style": "form",
        "explode": true
    }
    """)!.AsObject());

It's also possible to manually construct the parser.

var parameter = OpenAPI.ParameterStyleParsers.Parameter.Parse(
    name: "color",
    style: "form",
    location: "query",
    explode: true,
    new JsonSchema202012(JsonNode.Parse("""
    {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
    """)));
var parser = OpenAPI.ParameterStyleParsers.ParameterParsers.ParameterValueParser.Create(parameter);

Parse a style serialized parameter

string styleSerializedParameter = "color=blue&color=black&color=brown";
Console.WriteLine(
    parser.TryParse(styleSerializedParameter, out JsonNode? json, out string? error)
        ? json?.ToJsonString()
        : error);
// ["blue","black","brown"]

Serialize json to a parameter style.

var json = JsonNode.Parse("""
    ["blue","black","brown"]
""");
var styleSerializedParameter = parser.Serialize(json);
Console.WriteLine(styleSerializedParameter);
// color=blue&color=black&color=brown

Schema References

Json pointers represented as URI fragments are supported, other URI's are currently not. It is possible to bring your own Json Schema implementation though.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 62 6/7/2024
1.0.3-pre-5f844d02 53 6/7/2024
1.0.2 63 6/7/2024
1.0.2-pre-59512787 51 6/7/2024
1.0.1 76 6/4/2024
1.0.1-pre-974c1933 52 6/4/2024
1.0.0 61 5/29/2024
1.0.0-pre-fc3e8a7a 63 5/29/2024
1.0.0-pre-72c5ba6d 62 5/27/2024
1.0.0-pre-4465deeb 66 5/28/2024
0.1.2-pre-277f96df 65 5/24/2024
0.1.1 74 5/22/2024
0.1.1-pre-02a920e8 63 5/22/2024
0.1.0 112 4/17/2024
0.1.0-pre-62b5499b 83 4/17/2024

# [v1.0.0-pre-fc3e8a7a](https://github.com/Fresa/OpenAPI.ParameterStyleParsers/compare/47bb0e1c266a1644e9cee8e266ca4e720afac386...fc3e8a7a269a467c69b6e5fe9f0e5ba172f95d29) (2024-05-29)


### Features

* **json schema:** add built-in support for json schemas ([277f96d](https://github.com/Fresa/OpenAPI.ParameterStyleParsers/commit/277f96df6c21e9e9a251b6d958c84a7c70999082))
* **openapi:** parse parameter specifications ([2f693d9](https://github.com/Fresa/OpenAPI.ParameterStyleParsers/commit/2f693d954b30921321856fa929e5678126da5a63))


### BREAKING CHANGES

* **openapi:** The IJsonSchema abstraction has changed from JsonSchema.NET to an internally implemented one