Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple types support for parameters #401

Closed
buremba opened this issue Jul 2, 2015 · 4 comments
Closed

Multiple types support for parameters #401

buremba opened this issue Jul 2, 2015 · 4 comments

Comments

@buremba
Copy link

buremba commented Jul 2, 2015

I have a parameter that can be more than one type. (Consider an endpoint that takes an arbitrary key (string) and value (string, number or boolean) parameters and store them in a database.) It seems "parameter" object requires "type" field name and the value of "type" field must be one of "string", "number", "integer", "boolean", "array" or "file". Currently, I'm stuck with this problem since there's no workaround.

@jharmn
Copy link
Contributor

jharmn commented Feb 12, 2016

Link to parent #565

@jharmn
Copy link
Contributor

jharmn commented Sep 30, 2016

Now that we're working to include full JSON Schema support #741, and we have schema support for parameters #654, wouldn't we be able to handle this in the schema definition?
e.g. if string or integer were allowed for a parameter:

swagger.json

...
  "parameters": [
    {
      "name": "myParameter",
      "in": "query",
      "schema": {
        "$ref": "parameterSchema.json"
      }
    }
   ]

parameterSchema.json

{
  "oneOf":
  [
    {
      "type": "string"
    },
    {
      "type": "integer"
    }
  ]
}

@webron
Copy link
Member

webron commented Feb 22, 2017

This can now be done with oneOf.

@webron webron closed this as completed Feb 22, 2017
@akindo
Copy link

akindo commented Aug 21, 2023

It's described in the Inheritance and Polymorphism section of the OpenAPI documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants