Skip to content

Nullable reference types not reflected in generated properties #71

Description

@YVbakker

File: src/OpenApiSourceGenerator/Generators/PropertyGenerator.cs

Only the required OpenAPI keyword is mapped to the C# required modifier. Optional (non-required) reference-type properties (e.g. string, object references) are still emitted as non-nullable:

public class Pet
{
    public string Name { get; set; } // optional in the spec, but not nullable in C#
}

If the consuming project has <Nullable>enable</Nullable>, this produces CS8618 warnings for every optional reference-type property.

Suggested fix: Emit string? (or the appropriate nullable annotation) for non-required reference-type properties, or otherwise ensure generated code doesn't trigger nullable-context warnings by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions