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

Schema Object - "array" elements - mixed-up constraints and description #681

Closed
ilPittiz opened this issue Mar 7, 2022 · 3 comments
Closed

Comments

@ilPittiz
Copy link

ilPittiz commented Mar 7, 2022

When defining, within a Schema Object, an "array" element with both constraints (e.g. "minLength") and "description", they get mixed-up in unclear way.

RapiDoc version 9.2.0 (from CDN: https://unpkg.com/rapidoc@9.2.0/dist/rapidoc-min.js)

Example:

Schema
{
  "info": {
    "title": "Demo",
    "version": "0.0.1"
  },
  "openapi": "3.0.3",
  "paths": {
    "/api/v1/demo": {
      "post": {
        "operationId": "demo",
        "description": "Demo API",
        "parameters": [],
        "responses": {
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error key",
                      "type": "string",
                      "pattern": "^[a-z_]+$",
                      "minLength": 1
                    },
                    "invalidIds": {
                      "description": "List of invalid IDs",
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^ID[0-9]$"
                      },
                      "minItems": 1,
                      "maxItems": 1000
                    }
                  },
                  "required": [
                    "error",
                    "invalidIds"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "error": "invalid_id",
                  "invalidIds": [ "IDn" ]
                }
              }
            }
          }
        }
      }
    }
  }
}
Screenshot (comparison of "string" and "array" elements, both with constraints and description) schema_array_description
@mrin9
Copy link
Collaborator

mrin9 commented Mar 7, 2022

Can you provide me, how would you expect it to be displayed ?

@ilPittiz
Copy link
Author

ilPittiz commented Mar 7, 2022

Sorry, I should had been more explicit...
I'd expect the description on a stand-alone line, just like for "string" elements (hence the comparison in the screenshot):

Min` Items: 1 Max Items: 1000
Pattern: ^ID[0-9]$
List of invalid IDs

My original description was "Invalid IDs", and it seemed a bit weird to read "Max Items: 1000 Invalid IDs".

@mrin9 mrin9 closed this as completed in 3389320 Mar 27, 2022
mrin9 added a commit that referenced this issue Mar 27, 2022
@mrin9
Copy link
Collaborator

mrin9 commented Mar 27, 2022

after some discussion we decided to take the description at the top. This do create a problem of constrains being in the 2nd line and most likely be not shown in single line mode. but added an indicator for that

image

with descriptions expanded
image

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