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

Document Associative Arrays #21

Closed
barnaclebarnes opened this issue Jun 21, 2018 · 7 comments
Closed

Document Associative Arrays #21

barnaclebarnes opened this issue Jun 21, 2018 · 7 comments

Comments

@barnaclebarnes
Copy link

To output this:

name: {
  "en": "The Broad"
  "de": "De Broad"
}

We should be using a Dictionaries, HashMaps and Associative Arrays

This uses the additionalProperties but deifning this doesn't seem to work:

name: {type: Object, additionalProperties: String}

Outputs

"name": {
  "type": "object"
}

But should output (I think):

"name": {
  "type": "object"
  "additionalProperties" {
    "type": "string"
  }
}
@zhandao
Copy link
Owner

zhandao commented Jun 22, 2018

This specification has not been supported yet, I'll update later if you need. @barnaclebarnes

@barnaclebarnes
Copy link
Author

@zhandao That would be great. We are using this in quite a few places where were have translated fields. Now that I am starting to get my head around how this all works I'm loving it. Thanks!

@zhandao
Copy link
Owner

zhandao commented Jun 22, 2018

Hi, please update this gem from GitHub, and try it like f330d41#diff-917ffdde79050994c60fead0486d60fcR211

Here are two ways to define this specification:

  1. Use the keywords: additional_properties, add_prop, or values_type.
  2. Use { type: '{=>integer}' } instead of { type: Object }.

@barnaclebarnes
Copy link
Author

I think I have the additionalProperties outputting as per the proper spec but I think there is a bug in that every item now has "additionalProperties": { "type": "string"} added to the end of it.

api :show, 'This API gets the top level app metadata' do
  response '200', 'success', :json, data: {
    name: {type: '{=>string}' }, additionalProperties: { type: 'string'}
  }
end
      "/api/v3/app": {
      "get": {
        "summary": "This API gets the top level app metadata",
        "operationId": "show",
        "tags": [
          "Apps"
        ],
        "responses": {
          "200": {
            "description": "success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": {
                    "type": ""
                  }
                }
              }
            }
          }
        }
     

@zhandao
Copy link
Owner

zhandao commented Jun 22, 2018

data: {
    name: { type: '{=>string}' }, 
    additionalProperties: { type: 'string'}
}

Means that TWO fields in your form data body -- "name" and "additionalProperties".

"additionalProperties": {
    "type": ""
}

is a bug, I had fixed it, please update this gem.

@zhandao
Copy link
Owner

zhandao commented Jun 22, 2018

data: {
    name: { type: '{=>string}' }, 
}
# or
data: {
    name: { type: Object, additional_properties: 'string' }
}

are right ways.

@barnaclebarnes
Copy link
Author

All seems to work now.

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

2 participants