mikunn / openapi-schema-to-json-schema

Converts OpenAPI Schema Object to JSON Schema
75 stars 6 forks source link

schema with format overwrites minimum and maximum values #32

Open Shockolate opened 5 years ago

Shockolate commented 5 years ago

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#"
}
Lakitna commented 5 years ago

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

Lakitna commented 4 years ago

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

ghost commented 4 years ago

@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!

Lakitna commented 4 years ago

Yeah, I will when I get home today.

Lakitna commented 4 years ago

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

philsturgeon commented 4 years ago

Merged in new repo, you can close this.