question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow operationObject overloading with get-^ post-^ etc

See original GitHub issue

Currently under a pathItemObject, one can only define a single operationObject for each HTTP method (get, put, post, delete) etc. .

This limits OAS’ ability to express many APIs, particularly those which allow multiple semantically different POST or GET operations on the same resource, such as different sets of query parameters or produces/consumes media types and associated schema.

This is a request to explicitly allow for this. Several other OAI/OpenAPI-Specification issues touch on this (notably #146 and the many issues which referred to it since 2014), but an explicit proposal to resolve this and allow overloading so is not yet forthcoming (or if it is, I’m not sure where it is…)

The proposal is to allow pathItemObject with new patterned fields corresponding to each operation. That is in addition to

  get
  put
  post
  patch
  delete
  head
  options

we also allow patterned names

  get-^
  put-^
  post-^
  patch-^
  delete-^
  head-^
  options-^

This differs from my initial proposal in #146 which used period (.) as a separator instead of hyphen (-), i.e. post.optimize, post.merge.

@darrelmiller also noted he was considering this, using the hyphen (-) notation:

paths:
   /customers:
       get-by-email:
          parameters:
              email: ...
          responses: ...
       get-by-name:
          parameters:
              firstname: ...
              lastname: ...
          responses: ...

I feel segregation into individual operationObjects is the best solution because it is a natural extension of the current syntax (compared to turning a path item into an array) or complicating a operationObject with multiple sets of body/header/query parameters and/or response schema (which might require adding complicated discriminators/tags or other ways to link related response/parameters within one large all-encompasing operation object.)

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:9
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
darrelmillercommented, Sep 19, 2016

@MikeRalphson The hope was to make these scenarios something you didn’t have to “workaround”. I don’t like idea of telling people to put things in the path key that are not part of the URL path.

1reaction
darrelmillercommented, Sep 16, 2016

It’s not uglier than putting fragments on the end of paths. Or using oneOf in the schema and creating a union of query parameters. And it is definitely not uglier than the x-ms-paths solution.

I have no problem if OpenAPI wants to enforce that “style” of HTTP API, but we need to recognize that we are preventing people with perfectly valid HTTP APIs from being able to use OpenAPI to describe their APIs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Operator Overloading, C++ FAQ - Standard C++
Operator overloading allows C/C++ operators to have user-defined meanings on user-defined types (classes). Overloaded operators are syntactic sugar for ...
Read more >
Operator Overloading in C++ - GeeksforGeeks
For example, we can overload an operator '+' in a class like String so that we can concatenate two strings by just using...
Read more >
Is there a workaround for overloading the assignment operator ...
I'm doing a custom Number class for arithmetic operations with very large numbers and I want it to have the look-and-feel of the...
Read more >
C++ Operator Overloading Guidelines
(assignment operator); + - * (binary arithmetic operators) ... These guidelines are very important to follow, so definitely get in the habit early....
Read more >
Operator Overloading in C++ with examples | 2023
By overloading the operators, we can give additional meaning to the operators like +-*/=.,= etc., which by default are supposed to work only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found