Skip to content

2.0.12 regression: integer type replaced with number when enum values are present #1090

Closed

Description

@jmini

When an object properties has enum value defined:

openapi: 3.0.1
info:
  title: Object with enum test
  version: '1.0'
servers:
  - url: 'http://localhost:9999/'
paths:
  /ping:
    get:
      operationId: pingGet
      responses:
        '201':
          description: OK
components:
  schemas:
    SomeObj:
      type: object
      properties:
        iprop:
          type: integer
          format: int32
          enum:
            - 1
            - 2
        lprop:
          type: integer
          format: int64
          enum:
            - 1
            - 2
        nprop:
          type: number
          format: double
          enum:
            - 1.1
            - 1.2

With this code:

OpenAPIParser openApiParser = new OpenAPIParser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);

SwaggerParseResult parseResult = openApiParser.readLocation(inputSpec, null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
Schema someObj = openAPI.getComponents().getSchemas().get("SomeObj");
Map<String, Schema> properties = someObj.getProperties();

Schema iprop = properties.get("iprop");
System.out.println("iprop: " + iprop.getType());

Schema lprop = properties.get("lprop");
System.out.println("lprop: " + lprop.getType());

Schema nprop = properties.get("nprop");
System.out.println("nprop: " + nprop.getType());

With version 2.0.11 you get the expected result:

iprop: integer
lprop: integer
nprop: number

With version 2.0.12 it does not work:

iprop: number
lprop: number
nprop: number

=> The type is not the correct one.

Activity

  1. changed the title [-]2.0.12 regression:[/-] [+]2.0.12 regression: integer type replaced with number when enum values are present[/+] on May 3, 2019
  2. added a commit that references this issue on May 4, 2019
  3. added a commit that references this issue on May 5, 2019
  4. gracekarina commented on May 5, 2019

    @gracekarina
    Contributor

    thanks!
    Closed by #1092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions