openapi-schema-to-json-schema icon indicating copy to clipboard operation
openapi-schema-to-json-schema copied to clipboard

schema with format overwrites minimum and maximum values

Open Shockolate opened this issue 5 years ago • 6 comments

If a valid format is given, it overrides any given minimum and maximum values.

Consider:

    TestObject:
      type: object
      properties:
        overridingInt:
          type: integer
          format: int32
          minimum: 0
          maximum: 10
        overridingFloat:
          type: number
          format: float
          minimum: -5
          maximum: 10

results in:

{
  "type": "object",
  "properties": {
    "overridingInt": {
      "type": "integer",
      "format": "int32",
      "minimum": -2147483648,
      "maximum": 2147483647
    },
    "overridingFloat": {
      "type": "number",
      "format": "float",
      "minimum": -3.402823669209385e+38,
      "maximum": 3.402823669209385e+38
    }
  },
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Shockolate avatar May 24 '19 20:05 Shockolate

Same here. This is particularly a problem because our OAS guidelines state that all numbers (and integers) must have a format.

Lakitna avatar Aug 12 '19 13:08 Lakitna

Just a heads up that #35 is ready for merge as far as I'm concerned. This PR will solve the issue.

Lakitna avatar Nov 18 '19 10:11 Lakitna

@Lakitna -- Based on the comment in #35, do you plan on sending this PR to the new repo? This is a small but insanely helpful feature you created!

ghost avatar Jan 22 '20 14:01 ghost

Yeah, I will when I get home today.

Lakitna avatar Jan 22 '20 15:01 Lakitna

This issue will now be closed with the PR in the new repo: https://github.com/openapi-contrib/openapi-schema-to-json-schema/pull/2

Lakitna avatar Jan 22 '20 20:01 Lakitna

Merged in new repo, you can close this.

philsturgeon avatar Jan 29 '20 10:01 philsturgeon