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

Could not find the JSON path of a referenced schema #1429

Open
hyzx86 opened this issue Nov 4, 2021 · 4 comments · May be fixed by #1707
Open

Could not find the JSON path of a referenced schema #1429

hyzx86 opened this issue Nov 4, 2021 · 4 comments · May be fixed by #1707

Comments

@hyzx86
Copy link

hyzx86 commented Nov 4, 2021

It is recommended to throw a more detailed error message here
I debug the source code , here the clue is broken.

throw new InvalidOperationException("Could not find the JSON path of a referenced schema: " +

How do I output the error information here?

          if (mappings.Any(p => p.Value == null))
            {
                var errorItems = mappings.Where(p => p.Value == null).Select(x => x.Key.GetType().FullName);
                throw new InvalidOperationException("Could not find the JSON path of a referenced schema: " +
                                                     string.Join(",", errorItems) +
                                                    ",Manually referenced schemas must be added to the " +
                                                    "'Definitions' of a parent schema.");
            }
@JohnGalt1717
Copy link

I'm getting this error in nswag and I have no way to diagnose what the problem is as a result of this error message.

@bencyoung-Fignum
Copy link

I'm also seeing this. When I look at which one is missing a value, it appears to be a JsonSchema object with no values at all, but I can't see where it's coming from:

image

image

@bencyoung-Fignum
Copy link

Looks like it's trying to resolve the schema for a JValue property but getting null as a reference and then throwing this error

@hyzx86
Copy link
Author

hyzx86 commented Jun 24, 2024

It might be possible to add some custom filters to locate the problem in the following way

            services.AddSwaggerGen(options =>
            {
                options.UseInlineDefinitionsForEnums();
                options.DocumentFilter<SwaggerDocumentFilter>();
                options.CustomSchemaIds(type => type.Name);
                options.SchemaFilter<SwaggerEnumSchemaFilter>();
                options.OperationFilter<SwaggerOperationIdFilter>();
                options.OperationFilter<SwaggerOperationFilter>();
                options.ParameterFilter<SwaggerEnumParameterFilter>();
                options.CustomDefaultSchemaIdSelector();
...

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

Successfully merging a pull request may close this issue.

3 participants