Closed MartinDelVecchio closed 6 years ago
@MartinDelVecchio Sorry for late reply, the first thing I noticed is the way you wrote your parameter definition:
parameters:
- name: cls
description: Alarm class
in: query
schema:
$ref: '#/definitions/AlarmClass'
The Parameter.schema
can only be used when in
equals body
. You could rewrite your spec in this way and try again.
parameters:
- name: cls
description: Alarm class
in: query
type: string
enum:
- Network
- Service
- Storage
- System
Refer to here for details about Parameter
object (it would be much consistent in OpenAPI 3.0.0) and please feel free to contact if it still goes wrong.
It turns out that "enum types" cannot be referred to by $ref in Swagger 2.0.
Instead, I have to use the tag. For example, this type:
AlarmClass:
type: string
enum: &AlarmClassEnum
- Network
- Service
- Storage
- System
Has a tag &AlarmClassEnum. When I want to define a property of this type, I have to do this:
class:
type: string
enum: *AlarmClassEnum
Switching to this makes 'class' a string, which works.
I currently have a parameter 'cls' that is a string. I am able to execute an operation like this:
And it works. I then added an enum type for the class:
And change the parameter to use that type:
Now when I try to execute the operation, I get an error from pyswagger:
I am assuming that since the 'cls' parameter's underlying type is still a string, I should be able to specify it with cls='System'.
What am I missing?
Thanks.