Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6491
Closed
Open
Issue created May 29, 2020 by Administrator@rootContributor

[REQ][validate] Warn for validation keyword type mismatch

Created by: kevinoid

Currently validate does not warn if JSON Schema validation keywords are applied to schemas with types for which the validation keyword has no effect. For example:

openapi: '3.0.3'
info:
  title: Incorrect validation keyword example
  version: '1.0.0'
components:
  schemas:
    Vector3:
      type: array
      items:
        type: number
      maxLength: 3
      minLength: 3
paths:
  /location:
    get:
      operationId: getLocation
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Vector3'

openapi-generator-cli.jar validate -i openapi.yaml produces:

Validating spec (openapi.yaml)
No validation issues detected.

However, maxLength/minLength validate the length of strings and have no effect on Vector3, which has type: array. The author likely intended to use maxItems/minItems.

Is there any chance you'd consider producing a warning for such cases?

Thanks for considering, Kevin

Assignee
Assign to
Time tracking