Skip to content

Support custom keywords in schema generation #677

@ProTip

Description

@ProTip

Nuget Package

JsonSchema.Net

Package Version

6.0.3

Operating System

Linux

.Net Target (if relevant, please specify the version in the description)

.Net (5 or after)

A clear and concise description of the bug.

If I don't register the keyword by passing in a JsonSerializerContext it will throw the following error when serializing the schema:

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'UiPlaceholderKeyword' to type 'Json.Schema.UnrecognizedKeyword'

What did you expect?

The documentation does not mention needing a serializer context passed through, so I expected the schema to serialize without issue.

Please add test code or steps to reproduce the behavior.

Dotnet Fiddle: https://dotnetfiddle.net/hAgRn6

Is there any other information you'd like to share regarding this bug?

In #659 it was suggested this is due to running in an AOT context however:

  • I'm not running in an AOT context(initially was setting up a POC in LINQPad)
  • The documentation note added is missing information on arguments required for the overload

After moving my POC code from LINQPad to console project I was able to supply a JsonSerializerContext and confirm the schema would serialize without error.

P.S.: These Json projects are amazing and much appreciated.

Code of Conduct & Contributor Guidelines

  • I agree to follow this project's Code of Conduct and Contribution Guidelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions