Skip to content
This repository was 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
mlitwin wants to merge 2 commits into
apigee-127:masterfrom
mlitwin:issues-486
Open

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
mlitwin wants to merge 2 commits into
apigee-127:masterfrom
mlitwin:issues-486

Conversation

@mlitwin

@mlitwin mlitwin commented Apr 14, 2017

Copy link
Copy Markdown

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
Copy Markdown
Member

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

@cbayram cbayram left a comment

Copy link
Copy Markdown

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