Skip to content

openapi3gen.NewSchemaRefForValue panics for embedded pointer types #500

@cochran-at-niche

Description

@cochran-at-niche

Summary

openapi3gen.NewSchemaRefForValue panics if it encounters an embedded pointer type when a schema customizer is being used.

See here for a minimal example that reproduces the problem.

Explanation

I believe the panic is originating here in getStructField, because t.Field panics if the reflect.Type's Kind is not Struct (and in this case, it's Ptr). The panic only occurs when using a schema customizer because getStructField is only called (in this case) when a schema customizer is present (see here).

I believe this could be addressed by doing something like this in getStructField.

Here's a pull request that implements the fix: #501.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions