Skip to content

[Bug]: No maxLength label is displayed for arrays of items #1701

Closed

Description

@kosanna

Hey there, it seems there's some bug with rendering maxLength badges on array of items described by a schema.

Sample json property

        "bullets": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 80,
          }
        },

Expected behaviour: <=80 characters badge is displayed
Actual:
Screen Shot 2021-07-22 at 4 06 33 pm

redoc-cli v0.10.4

Note:

  • Could not find anything that says it's been fixed in subsequent version.
  • Also could not find any migration guide from 10 to 11, seems to be breaking.

Any advice or help is greatly appreciated. Thank you!

Activity

  1. ihah commented on Aug 10, 2021

    @ihah

    Instead of creating new issue just making confirmation on array items string type rules.
    Confirming redoc-cli v0.12.2 has same behavior, pattern, description, minLength, maxLength rule badges are not rendered.
    Enum rendered.

    starts:
        type: array
        items:
          type: string
          description: "My start list"
          minLength: 3
          maxLength: 100
        maxItems: 12
    starts:
        type: array
        items:
          type: string
          description: "My start list"
          pattern: /([A-Z])/
        maxItems: 12

    It seems enum rule works:

    starts:
        type: array
        items:
          type: string
          enum: [Jr. Test, Dr. Tester]
        maxItems: 12

    image

    Maybe pattern, description, minLength, maxLength string rules should be rendered same as enum rule.

    With pattern, minLength, maxLength string rules
    Items pattern: A-Z
    Items length: [ 3 .. 100 ] characters

    With maxLength string rule
    Items length: <= 100 characters

    With minLength string rule
    Items length: >= 10 characters

  2. miqh commented on Oct 7, 2021

    @miqh
    Contributor

    I don't believe the current implementation will show constraint badges for array item types.

    In situations where constraint badges appear next to array-based fields, they refer to the constraint applying to the array itself. An example is maxItems, as pointed out in a previous comment.

    The additional problem here is how best to present the array item type constraints.

    A naive (and I think quick) solution would be to collect and stack all array item type constraints adjacent to array constraints. However, this mightn't read intuitively.

    Example:

    Array of strings [<= 3 items] [<= 80 characters]
    ...
    

    @RomanHotsiy, if you've got any opinions on how best to present the array item type constraints, I can have a shot at making changes to support them.

  3. RomanHotsiy commented on Oct 8, 2021

    @RomanHotsiy
    Member

    I believe there is a PR already in progress related to this but I have to check if this is considered. See the mentioned PR above.

  4. self-assigned this
    on Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions