OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Consider adding `Path` and `Type` properties to `OpenApiOperation`

Open glen-84 opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

If you have an operation object, there's no way to access the path or type of the operation without iterating over all paths so that you have access to this information. It seems logical for these to be properties of the operation, even if this is structured differently in the actual document text.

Describe the solution you'd like

Consider setting operation.Type and operation.Path to the applicable values.

Describe alternatives you've considered

  1. Storing this information separately, in a dictionary like:
    Dictionary<string, (OperationType OperationType, string Path, OpenApiOperation Operation)>
    
  2. Storing this information in Extensions.

Additional context

n/a

glen-84 avatar May 03 '24 10:05 glen-84

Working on it...

Agnibaan avatar May 29 '24 05:05 Agnibaan

Hi @glen-84 Thank you for using the SDK and for reaching out.

The goal of the object model is to provide a simple API that reflects the specification. Adding back-reference properties (or dictionary entries) would have negative performance impacts, and could also lead to "out of synchronization" bugs.

If you could share more context about what you're trying to achieve, maybe there's a better approach.

Let us know if you have any additional comments or questions.

baywet avatar May 19 '25 19:05 baywet

Hi @baywet

This was over a year ago, so it's not as fresh in my mind, but we were adding the ability to access an OpenAPI service via GraphQL.

While converting REST operations to GraphQL operations, we needed to know the type of each operation in order to map it to a query or mutation.

We ended up wrapping each operation with an OpenApiOperationWrapper, that includes the operation, type, and path.

It just seemed like these were properties of the operation, so it may have made sense to provide them there, but if you want it to be a strict reflection of the source text, then that's fine and you can close this issue.

Thanks.

glen-84 avatar May 25 '25 08:05 glen-84

Thank you for the additional information. Closing

baywet avatar Jun 02 '25 16:06 baywet