Skip to content

integer support broken with yaml #482

@cboitel

Description

@cboitel

Two use cases:

  1. use openapi3 to load a document and ensure some data unarmshaled from a file complies with one of the schema (using VisitJSON)
  2. use openapi3.filter to validate a request complies with a loaded openapi document

In both use cases, if a schema references a type integer and data was unmarshaled from YAML, we end up with " unhandled value of type int" error. If file or request is using JSON, no error is reported.
=> for a file, one can workaround the issue by marshaling the read YAML to JSON and unmarshal it back from JSON
=> for openapi3filter, no workaround found as of today.

I believe this is due to the wrong assumption that all numbers will be using float type as this is the case for JSON (no integers, only floats => json unmarshaling returns float only)
=> https://github.com/getkin/kin-openapi/blob/master/openapi3/schema.go#L795 only references float
=> https://github.com/getkin/kin-openapi/blob/master/openapi3/schema.go#L998 checks for integers but not its format (int32/64)

Support for integers type and its associated formats (int32/int64) is required for non-JSON content-types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions