Skip to content

Creating reference schema is not working #1947

@Blqck666

Description

@Blqck666

Describe the bug
A clear and concise description of what the bug is.
i'm trying to build OpenApiDoc where i declare a predefined type, and i want to create a reference to that type dynamically.
i have object account , that have a field of type address , i want in openapi doc to reference the predefined object

OpenApi File To Reproduce
Add the OpenApi file you're using or a link to it as well as the steps to reproduce the current behavior.
the file is so big but theres some screenshots.
Image
Image

Expected behavior
A clear and concise description of what you expected to happen.
the field should have reference of type address. like this :
Image

Screenshots/Code Snippets
If applicable, add screenshots of the stack trace or a code snippet to help explain your problem.
If applicable, add a link to your project

public static void AddAddressSchema(this OpenApiDocument openApiDoc)
    {
        var addressSchema = new OpenApiSchema
        {
            Type = ObjectType,
            Properties = new Dictionary<string, OpenApiSchema>
            {
                { "City", new OpenApiSchema { Type = StringType, Nullable = true } },
                { "Country", new OpenApiSchema { Type = StringType, Nullable = true } },
                { "CountryCode", new OpenApiSchema { Type = StringType, Nullable = true } }
            }
        };

        openApiDoc.Components.Schemas.Add(AddressType, addressSchema);
    }

and to assign any field that have type address i'm doing this :

OpenApiSchema AssignPredefinedSchemaReference(string id)
        {
            return new OpenApiSchema
            {
                Reference = new OpenApiReference()
                {
                    Type = ReferenceType.Schema,
                    Id = id
                }
            };
        }

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions