Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

Support null-returning operations #5340

Description

@aelij

Describe the issue or request
Currently operations that return null don't check for this option, so the deserialization fails. For example:

  @get
  myOp(): MyModel[] | null;

generates:

            using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
            List<MyModel> array = new List<MyModel>();
            foreach (var item in document.RootElement.EnumerateArray())
            {
                array.Add(MyModel.DeserializeMyModel(item));
            }

Describe your ideas for solutions
Check if the root element is a JSON null and if so return null.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v3Version 3 of AutoRest C# generator.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions