-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Hasmaps payloads #593
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
Comments
Update: This answer is not helpful, as I misunderstood the question. The values are meant to be anything, not the keys.) I guess one reason for this is that JSON allows only String keys in key-value pairs in a object. A possible workaround would be to use an array with "pair" objects, which works already now: definitions:
my_hashmap:
type: array
items:
type: object
properties:
key:
# your key type, for example
type: object
properties:
name: string
value:
# your value type, for example
type: object
properties:
example: integer A value of this type could look like this: [ {"key": { "name": "Paul" }, "value": { "example": 42 } },
{"key": { "name": "gedaiu" }, "value": { "example": 17 } } ] |
1+; we have several cases where we want to allow an arbitrary attributes object of name/value pairs. We're happy with just string keys but desire values being scalars, arrays or nested maps. |
Isn't that supported by @gedaiu @DavidBiesack can you provide a sample of such payload? Not a schema of it, just what you want to payload to be. |
@webron yes, here it is my case:
where |
Are any properties in that payload arbitrary? If not, there's no problem describing that with the current version of the spec. |
@webron sorry... maybe my comment was not that clear... the |
@gedaiu then you just define variables as this: variables:
type: object
additionalProperties: {} If you want to limit the type of the variables, say to integers: variables:
type: object
additionalProperties:
type: integer This is supported by the current version of the spec. |
uf... I did not saw that... thanks! |
@gedaiu no problem. @DavidBiesack - if you feel something isn't covered, can you please elaborate? |
Maybe we could have some examples/recipes/... showcasing how someone might do things like this? I can think of other "oh, I didn't know you could do that" scenarios as well. |
Sure. Parent: #589 |
Thanks Ron. You're a gentleman and a scholar. |
parent issue #579
I would be nice to be able to define hashmaps payloads.
I have an use case in an app, where I want to send a list of variables, defined by user. With the 2.0 spec, there is no way of defining a schema object that can contains any key like a Json object...
The text was updated successfully, but these errors were encountered: