swagger-api / swagger-api/swagger-ui
maxLength has no effect on non strings - swagger-ui tries to outsmart the creator
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: [e.g. macOS] ubuntu
- Browser: [e.g. chrome, safari] chromium
- Version: [e.g. 22] 121.0.6167.85 (Official Build) snap (64-bit)
- Method of installation: [e.g. npm, dist assets] webbrowser see next
- Swagger-UI version: [e.g. 3.10.0] https://editor.swagger.io/ and also https://editor-next.swagger.io/
- Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0] 30.3
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.3
info:
title: Swagger Petstore - OpenAPI 3.0
version: 1.0.11
paths:
/user/logout:
get:
tags:
- user
summary: Logs out current logged in user session
description: ''
operationId: logoutUser
parameters: []
responses:
default:
description: successful operation
components:
schemas:
User:
type: object
properties:
email:
type: string
# maxLength is shown
maxLength: 50
example: john@email.com
password:
type: object
# maxLength is not shown
maxLength: 30
properties:
label:
type: string
Swagger-UI configuration options:
default config of https://editor-next.swagger.io/ and https://editor.swagger.io/
Describe the bug you're encountering
https://editor-next.swagger.io/ outputs the warning:
maxLength has no effect on non strings
and thus it is not shown. I don't mind if a warning is emitted but the maxLength should not just be stripped from password
To reproduce...
Steps to reproduce the behavior:
- Go to maxLength has no effect on non strings
- Paste the example above
- See warning at the bottom left
Expected behavior
swagger-ui should not try to outsmart the creator of the spec. The above example is valid so swagger-ui should show all properties
Screenshots
Additional context or thoughts
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in editor-next.swagger.io using the provided OpenAPI schema, then trace the warning and schema rendering path for maxLength on the password object. Done means the example's maxLength remains visible for the non-string property while the existing behavior for the string property is preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100