Neuro.Content.OpenApi 1.1.1

dotnet add package Neuro.Content.OpenApi --version 1.1.1
                    
NuGet\Install-Package Neuro.Content.OpenApi -Version 1.1.1
                    
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="Neuro.Content.OpenApi" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Neuro.Content.OpenApi" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Neuro.Content.OpenApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Neuro.Content.OpenApi --version 1.1.1
                    
#r "nuget: Neuro.Content.OpenApi, 1.1.1"
                    
#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.
#:package Neuro.Content.OpenApi@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Neuro.Content.OpenApi&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Neuro.Content.OpenApi&version=1.1.1
                    
Install as a Cake Tool

Neuro.Content.OpenApi

An OpenAPI 3.0.x content codec for the TAG Neuron®. This library provides parsing and serialization of OpenAPI (Swagger) specification documents in JSON format, integrated with the Waher.Content framework.

Overview

Neuro.Content.OpenApi implements both IContentEncoder and IContentDecoder from the Waher.Content framework. It is automatically discovered via Waher.Runtime.Inventory, enabling the TAG Neuron to natively handle OpenAPI documents without additional configuration.

The library provides a complete, strongly-typed object model for OpenAPI 3.0.x specifications along with bidirectional JSON serialization.

Features

  • Full OpenAPI 3.0.x document model (paths, operations, schemas, security, components)
  • JSON parsing via FromDictionary() factory methods on each model type
  • JSON serialization via ToDictionary() on each model type
  • Polymorphic schema deserialization (string, integer, number, boolean, array, object, oneOf, allOf, $ref)
  • Seamless integration with the Waher.Content codec pipeline

Project

Project Framework Description
Neuro.Content.OpenApi .NET Standard 2.1 OpenAPI content codec for the TAG Neuron®

Installation

The library is distributed as a NuGet package:

dotnet add package Neuro.Content.OpenApi

Or via the Package Manager Console:

Install-Package Neuro.Content.OpenApi

Usage

Decoding an OpenAPI document from JSON

using Neuro.Content.OpenApi.Model;
using Waher.Content;

// Parse a JSON string into a dictionary
Dictionary<string, object> dict = (Dictionary<string, object>)JSON.Parse(jsonString);

// Deserialize into the strongly-typed model
OpenApiDocument document = OpenApiDocument.FromDictionary(dict);

// Access API metadata
string title = document.Info?.Title;
string version = document.Info?.Version;

// Iterate paths and operations
foreach (var kvp in document.Paths)
{
    string path = kvp.Key;
    OpenApiPathItem pathItem = kvp.Value;

    if (pathItem.Get != null)
        Console.WriteLine($"GET {path} - {pathItem.Get.Summary}");
}

Encoding an OpenAPI document to JSON

using Neuro.Content.OpenApi.Model;
using Waher.Content;

// Build a document programmatically
OpenApiDocument document = new OpenApiDocument
{
    Info = new OpenApiInfo
    {
        Title = "My API",
        Version = "1.0.0",
        Description = "A sample API"
    }
};

document.Servers.Add(new OpenApiServer { Url = "https://api.example.com" });

// Serialize to a JSON-compatible dictionary
Dictionary<string, object> dict = document.ToDictionary();

// Encode to JSON string
string json = JSON.Encode(dict, false);

Working with schemas

The library supports polymorphic schema types via the abstract OpenApiSchema base class:

using Neuro.Content.OpenApi.Model;

// Access component schemas
if (document.Components != null)
{
    foreach (var kvp in document.Components.Schemas)
    {
        string name = kvp.Key;
        OpenApiSchema schema = kvp.Value;

        if (schema is OpenApiObjectSchema obj)
        {
            foreach (var prop in obj.Properties)
                Console.WriteLine($"  {prop.Key}: {(prop.Value as ITypedSchema)?.Type}");
        }
    }
}

Object Model

Core Types

Class Description
OpenApiDocument Root document representing a complete OpenAPI 3.0.x spec
OpenApiInfo API metadata (title, version, description, contact, license)
OpenApiContact Contact information for the API
OpenApiLicense License information for the API
OpenApiServer Server connectivity information
OpenApiPathItem Operations available at a specific path
OpenApiOperation A single API operation (parameters, request body, responses)
OpenApiParameter Path, query, header, or cookie parameter
OpenApiRequestBody Request body definition
OpenApiResponse Response definition
OpenApiMediaType Media type with schema reference
OpenApiComponents Reusable schemas, parameters, responses, security schemes
OpenApiSecurityScheme Authentication mechanism definition
OpenApiSecurityRequirement Security requirement declaration

Schema Types

Class OpenAPI type Description
OpenApiSchema (abstract base) Common properties: description, nullable, example, default
OpenApiStringSchema string String with format, minLength, maxLength, enum
OpenApiIntegerSchema integer Integer with format (int32, int64)
OpenApiNumberSchema number Number with format (float, double)
OpenApiBooleanSchema boolean Boolean value
OpenApiArraySchema array Array with items schema
OpenApiObjectSchema object Object with properties and required list
OpenApiOneOfSchema (composition) oneOf schema composition
OpenApiAllOfSchema (composition) allOf schema composition
OpenApiRefSchema (reference) $ref pointer to another schema

Other Types

Type Description
HttpMethod Enum: Get, Post, Put, Delete, Patch, Head, Options, Trace
ITypedSchema Interface for schemas that expose a Type property
OpenApiJsonCodec The IContentEncoder/IContentDecoder implementation

Dependencies

NuGet Package Description
Waher.IoTGateway IoT Gateway hosting environment and content framework
Waher.Runtime.Inventory Runtime type inventory and inversion of control (IoC)

Building

Prerequisites

  • .NET SDK supporting .NET Standard 2.1 (e.g., .NET Core 3.0+ or .NET 5+)
  • The IoT Gateway repository cloned to C:\My Projects\IoTGateway (for post-build events), or an installed TAG Neuron®

Compile

dotnet build

Package

dotnet pack

The project is configured with <GeneratePackageOnBuild>true</GeneratePackageOnBuild>, so a NuGet package is produced on every build.

Repository

License

Copyright © Trust Anchor Group AB. All rights reserved.

This project is licensed under the Trust Anchor Group License. It permits personal evaluation, academic use (with attribution), and security analysis. Commercial use requires a separate license from Trust Anchor Group.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.1 0 6/22/2026
1.1.0 29 6/22/2026
1.0.0 54 6/16/2026

Initial release.