Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Create default implementation for JSchemaGenerationProvider #344

Open
Drake53 opened this issue May 11, 2024 · 0 comments

Comments

@Drake53
Copy link

Drake53 commented May 11, 2024

Currently, the GetSchema method in JSchemaGenerationProvider is abstract. This makes it harder to implement a custom provider, because you can't simply call base.GetSchema(context); and add something on top of that.

As a workaround, I now implemented the custom provider as follows:

public override JSchema GetSchema(JSchemaTypeGenerationContext context)
{
  context.Generator.GenerationProviders.Remove(this);
  var schema = context.Generator.Generate(context.ObjectType, context.Generator.DefaultRequired, context.MemberProperty);
  context.Generator.GenerationProviders.Add(this);

  // custom generator implementation

  return schema;
}

It would be nice if this could be simplified to:

public override JSchema GetSchema(JSchemaTypeGenerationContext context)
{
  var schema = base.GetSchema(context);

  // custom generator implementation

  return schema;
}

Note that the workaround does not work when creating a schema for an object with nested entities, because then the custom generation provider is only applied to the root object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant