OPC UA runtime schema generation (XSD, OPC Binary and JSON Schema) for encodeable and complex data types.
Install
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard | |
| Other |
README
OPCFoundation.NetStandard.Opc.Ua.Core.Schema
Runtime schema generation for OPC UA data types.
This package produces schemas for the encodeable types generated by the OPC UA stack and for complex types that are added dynamically at runtime. Schemas are built as strongly-typed object models in code (no embedded schema strings), so unused generation paths are trimmed away and the feature is NativeAOT friendly.
Supported encodings:
- XSD for the XML encoding.
- BSD (OPC Binary, Part 6) for the binary encoding.
- JSON Schema (Part 6 Annex C) for the JSON encoding, in both compact (reversible) and verbose flavors.
Usage
IServiceProvider services = new ServiceCollection()
.AddOpcUa()
.AddSchemaGeneration()
.Services
.BuildServiceProvider();
ISchemaProvider provider = services.GetRequiredService<ISchemaProvider>();
if (provider.TryGetSchema(typeId, UaSchemaFormat.JsonCompact, UaSchemaScope.Type, out IUaSchema? schema))
{
string json = schema.ToSchemaString();
}
The provider can also be assembled without dependency injection:
IDataTypeDefinitionResolver resolver = new DataTypeDefinitionRegistry();
ISchemaProvider provider = new DefaultSchemaProvider(
resolver,
[
new JsonSchemaGenerator(),
new XsdSchemaGenerator(),
new BsdSchemaGenerator()
]);
Generated model registration extensions add public structure and enumeration activators
to an IEncodeableFactory. Use EncodeableFactoryDefinitionSource when schemas should be
resolved directly from those compiled definitions instead of a manual registry.
See docs/SchemaGeneration.md in the repository for details.
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.