Skip to content

OpenAPI v2 parameter type does not allow for string value #1135

@CubicrootXYZ

Description

@CubicrootXYZ

I am trying to parse a OpenAPI v2/swagger document and the unmarshaling of the swagger petstore example into openapi2.T fails with string was used where sequence is expected.

This is the code snippet I am using for unmarshaling the file:

	var doc openapi2.T
	input, err := os.ReadFile(file)
	if err != nil {
		panic(err)
	}
	err = yaml.Unmarshal(input, &doc)
	if err != nil {
		panic(err)
	}

The unmarshaling seems to fail as all the operation parameters use the type key with a string value, but with commit 672dc3233232be7cb1485f3b87bcae981693bd91 openapi2.T requires an array of strings now. Which seems to not be in accordance with the OpenAPI v2 spec.

I'd love seeing this being changed back to be a string value for the OpenAPI v2 package of kin-openapi


Minimal excerpt from the swagger document with the problematic attribute:

paths:
  /pets:
    get:
      description: |
        Returns all pets from the system that the user has access to
      operationId: findPets
      parameters:
        - name: tags
          in: query
          description: tags to filter by
          required: false
          type: array  # <---- the unmarshaling fails here as it expects an array of strings and not a string value
          collectionFormat: csv
          items:
            type: string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions