Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Fix Issue 486: For a POST with body taking an array of strings, elements of the array can be improperly coerced into numeric values. #499

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mlitwin
Copy link

@mlitwin mlitwin commented Apr 14, 2017

In swagger 2, a parameter in body will have a .schema, rather than be a schema: http://swagger.io/specification/#parameterObject
getParameterType() is already savvy to this, so we do what it does for the schema.

Without this, you get a bogus schema, which eventually leads to converValue thinnking it's got an object type (the default), and attempting to JSON.stringify the nice string into an object.

Matthew Litwin added 2 commits April 14, 2017 13:49
… when body is array.

In swagger 2, a parameter in body will have a .schema, rather than be a schema: http://swagger.io/specification/#parameterObject
getParameterType() is already savvy to this, so we do what it does for the schema.

Without this, you get a bogus schema, which eventually leads to converValue thinnking it's got an object type (the default), and attempting to JSON.stringify the nice string into an object.
@whitlockjc
Copy link
Member

I'll give it a peek when releasing in a few days.

Copy link

@cbayram cbayram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other places in the function where schema assumes top-level definition. How about resolving the schema level at the beginning of the function?

  if (schema.schema) {
    schema = schema.schema;
  }
  val = mHelpers.convertValue(val, schema, mHelpers.getParameterType(schema), location);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants