Skip to content

OAS2: invalid spec created for mandatory formData parameters #76

@antaln

Description

@antaln

Describe the bug

Building an OAS2 spec against vSphere vCenter 8.0u3 results in vcenter.json that does not pass OAS2 validation.

For example, Swagger-cli reports:

Swagger schema validation failed.
  #/basePath must match pattern "^/"
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must have required property 'schema'
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must NOT have additional properties
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/in must be equal to one of the allowed values
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/required must be boolean
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/required must be boolean
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/in must be equal to one of the allowed values
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/required must be boolean
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/required must be boolean
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/in must be equal to one of the allowed values
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/required must be boolean
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/required must be equal to one of the allowed values
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0/in must be equal to one of the allowed values
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must match exactly one schema in oneOf
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must match exactly one schema in oneOf
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must have required property '$ref'
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must NOT have additional properties
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must NOT have additional properties
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must NOT have additional properties
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must NOT have additional properties
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must NOT have additional properties
  #/paths/~1api~1vcenter~1authentication~1token/post/parameters/0 must match exactly one schema in oneOf

Analysis shows that formData mandatory parameter of POST /api/vcenter/authentication/token has field "required":"true" instead of "required":true.

The root cause appears to be:

Similar mistype is observed also here:

(Edited: updated to correct parameter type and suspected code line)

Reproduction steps

  1. python vmsgen.py -vc <vcenter-8.0u3-host -oas 2 -o generated
  2. swagger-cli validate generated/vcenter.json

Expected behavior

Required mandatory parameters should result in a valid OAS2 spec.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions