Pass parameter to $ref in OpenAPI 3


some development

Suppose I have the following schema for later use $ref:

"schemas": {
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "petId": {
            "type": "integer",
            "format": "int64"
          }
        }
      }

But I have another schema similar to this:

"schemas": {
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "itemId": {
            "type": "integer",
            "format": "int64"
          }
        }
      }

The only difference between them is itemIdand petId, when I just want to create a schema and pass itemIdor petIdreference. How do i do this? Is there any other solution?

Alexis

Indeed, there is no way to pass parameters along pattern references.

In your case what we can do is have a base schema with Orderonly common properties and then a separate schema for petId/ itemId Orders to use .allOf

Check this answer for another example (or this for a more specific one!).

Related


Pass parameter to $ref in OpenAPI 3

some development Suppose I have the following schema for later use $ref: "schemas": { "Order": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "petI

Pass literal as const ref parameter

innocent bystander Imagine the following simplified code: #include <iostream> void foo(const int& x) { do_something_with(x); } int main() { foo(42); return 0; } (1) Besides optimization, what happens when 42 is passed to foo? Does the compiler stick 42 somew

Pass literal as const ref parameter

innocent bystander Imagine the following simplified code: #include <iostream> void foo(const int& x) { do_something_with(x); } int main() { foo(42); return 0; } (1) Besides optimization, what happens when 42 is passed to foo? Does the compiler stick 42 somew

Pass literal as const ref parameter

innocent bystander Imagine the following simplified code: #include <iostream> void foo(const int& x) { do_something_with(x); } int main() { foo(42); return 0; } (1) Besides optimization, what happens when 42 is passed to foo? Does the compiler stick 42 somew

Pass literal as const ref parameter

innocent bystander Imagine the following simplified code: #include <iostream> void foo(const int& x) { do_something_with(x); } int main() { foo(42); return 0; } (1) Besides optimization, what happens when 42 is passed to foo? Does the compiler stick 42 somew

Pass literal as const ref parameter

innocent bystander Imagine the following simplified code: #include <iostream> void foo(const int& x) { do_something_with(x); } int main() { foo(42); return 0; } (1) Besides optimization, what happens when 42 is passed to foo? Does the compiler stick 42 somew

Python pass ref int as parameter

Mr. Sha The tlb library in my python project passes win32com.client. I've easily used a number of built-in functions, but one of the main functions takes a list of arguments for two of them marked as ref int. When I try to pass a python integer to the function

Pass array as query parameter in Swagger OpenApi 3.0

Fractal 397 I currently give the following code to get a set of values as query parameters (in Node-express, nodejs v14.17 and OpenAPI version 3.0.1), - name: abcd description: abcd in: query required: false sche

Swagger/OpenAPI - use $ref to pass reusable defined parameters

brandonscript: Suppose I have a similar parameter limit. This place is used everywhere, and if I need to update it, it's a pain to have to change it everywhere: parameters: - name: limit in: query description: Limits the number of returned resu

Swagger/OpenAPI - use $ref to pass reusable defined parameters

brandonscript: Suppose I have a similar parameter limit. This place is used everywhere, and if I need to update it, it's a pain to have to change it everywhere: parameters: - name: limit in: query description: Limits the number of returned resu

Swagger/OpenAPI - use $ref to pass reusable defined parameters

brandonscript: Suppose I have a similar parameter limit. This place is used everywhere, and if I need to update it, it's a pain to have to change it everywhere: parameters: - name: limit in: query description: Limits the number of returned resu

Pass delegate/event as ref generic parameter

Sergio Romero We are dealing with a lot of legacy WinForms code and are slowly refactoring, breaking down dependencies, implementing the MVP pattern and moving logic from forms and user controls into the presenter. We've added Castle Windsor, which creates a V

Pass ref as function parameter React Native

Brinto In the current code, I use ref to change TextInputthe style of a component that uses a function in a method setNativeProps. class RegisterScreen extends Component { constructor(props) { super (props) this.state = { border

Pass ref as function parameter React Native

Brinto In the current code, I use ref to change TextInputthe style of a component that uses a function in a method setNativeProps. class RegisterScreen extends Component { constructor(props) { super (props) this.state = { border

How to pass parameter to member variable by ref?

JS Pretty new to C#, coming from a C++ background a long time ago, so I seem to be having trouble transitioning from pointers to refs in C#. I have a class (EColour) created with the constructor shown. I assign (or at least try to) a reference to cellTemplate

Pass ref as function parameter React Native

Brinto In the current code, I use ref to change TextInputthe style of a component that uses a function in a method setNativeProps. class RegisterScreen extends Component { constructor(props) { super (props) this.state = { border

Pass ref as function parameter React Native

Brinto In the current code, I use ref to change TextInputthe style of a component that uses a function in a method setNativeProps. class RegisterScreen extends Component { constructor(props) { super (props) this.state = { border

Pass delegate/event as ref generic parameter

Sergio Romero We are dealing with a lot of legacy WinForms code and are slowly refactoring, breaking down dependencies, implementing the MVP pattern and moving logic from forms and user controls into the presenter. We've added Castle Windsor, which creates a V

Pass ref as function parameter React Native

Brinto In the current code, I use ref to change TextInputthe style of a component that uses a function in a method setNativeProps. class RegisterScreen extends Component { constructor(props) { super (props) this.state = { border

Pass ref as function parameter React Native

Brinto In the current code, I use ref to change TextInputthe style of a component that uses a function in a method setNativeProps. class RegisterScreen extends Component { constructor(props) { super (props) this.state = { border

Spring Boot OpenAPI 3 - How to pass pagination details?

Pra_A I hope to develop Spring Boot + OpenAPI 3 example by looking at https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/ and https://techsparx.com/ software-development/openapi/spring-boot-rest-api-docs.html . In th

Spring Boot OpenAPI 3 - How to pass pagination details?

Pra_A I hope to develop Spring Boot + OpenAPI 3 example by looking at https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/ and https://techsparx.com/ software-development/openapi/spring-boot-rest-api-docs.html . In th

Spring Boot OpenAPI 3 - How to pass pagination details?

Pra_A I hope to develop Spring Boot + OpenAPI 3 example by looking at https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/ and https://techsparx.com/ software-development/openapi/spring-boot-rest-api-docs.html . In th

Spring Boot OpenAPI 3 - How to pass pagination details?

Pra_A I hope to develop Spring Boot + OpenAPI 3 example by looking at https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/ and https://techsparx.com/ software-development/openapi/spring-boot-rest-api-docs.html . In th