Skip to content

Copy the line number to OpenApiError.Pointer if known #502

Closed as not planned

Description

Some methods in Microsoft.OpenApi.Readers throw an OpenApiException whose Exception.Message includes a line number. I would like to have all of these line numbers available in OpenApiError.Pointer, to make them easier to parse automatically.

throw new OpenApiException(
$"Expected list at line {_nodeList.Start.Line} while parsing {typeof(T).Name}");

throw new OpenApiException(
$"Expected list at line {_nodeList.Start.Line} while parsing {typeof(T).Name}");

throw new OpenApiException($"Expected map at line {yamlMap.Start.Line} while parsing {typeof(T).Name}");

throw new OpenApiException($"Expected map at line {yamlMap.Start.Line} while parsing {typeof(T).Name}");

throw new OpenApiException($"Expected map at line {yamlMap.Start.Line} while parsing {typeof(T).Name}");

throw new OpenApiException($"Expected scalar at line {_node.Start.Line} for key {key.GetScalarValue()}");

throw new OpenApiException($"Expected scalar at line {node.Start.Line}");

Activity

  1. AP-G commented on Sep 3, 2020

    @AP-G

    This indeed would be very helpful!

    In addition, it would be nice if the diagnostic object supported error levels like "Warning", "Error". This would allow a better distinction for exceptions that can be actively ignored in processing.

    Furthermore, it would be very helpful if the errors were categorized or numbered. Then they could be processed more easily instead of having to parse the strings.

  2. added
    type:enhancementEnhancement request targeting an existing experience
    goodfirstissueStandard GitHub label used for easy to resolve issues targeting beginner contributors
    on Sep 28, 2020
  3. added this to the Backlog milestone on Sep 28, 2020
  4. darrelmiller commented on Apr 29, 2025

    @darrelmiller
    Member

    OpenAPI.Net now supports errors and warnings, but unfortunately System.Text.Json does not support exposing line numbers.

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

    goodfirstissueStandard GitHub label used for easy to resolve issues targeting beginner contributorstype:enhancementEnhancement request targeting an existing experience

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions