swagger-ui
swagger-ui copied to clipboard
maxLength has no effect on non strings - swagger-ui tries to outsmart the creator
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: [email protected]
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