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

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

Closed
kosanna opened this issue Jul 22, 2021 · 3 comments · Fixed by #1765
Closed

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

kosanna opened this issue Jul 22, 2021 · 3 comments · Fixed by #1765
Assignees

Comments

@kosanna
Copy link

kosanna commented Jul 22, 2021

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!

@ihah
Copy link

ihah commented Aug 10, 2021

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

@miqh
Copy link
Contributor

miqh commented Oct 7, 2021

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.

@RomanHotsiy
Copy link
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.

@zalesky zalesky self-assigned this Oct 8, 2021
zalesky pushed a commit that referenced this issue Oct 12, 2021
Oprysk added a commit that referenced this issue Jan 5, 2022
* fix: No maxLength label is displayed for arrays of items #1701

* Revert "fix: No maxLength label is displayed for arrays of items #1701"

This reverts commit 543ecc4.

* fix: No maxLength label is displayed for arrays of items #1701

* change array items display

* fix alignment

* remove theme font from labels

* update snapshot

Co-authored-by: Oprysk <vyacheslav@redocly.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants