Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser cannot process 'allOf' correctly #1367

Closed
ronny-stauffer opened this issue May 8, 2020 · 2 comments
Closed

Parser cannot process 'allOf' correctly #1367

ronny-stauffer opened this issue May 8, 2020 · 2 comments
Assignees
Milestone

Comments

@ronny-stauffer
Copy link

In an example I defined the schema for a data structure with a single property which has an enumeration type. I use the allOf keyword (as a wrapper construct) in order to be allowed to also specify a description for the property:

components:
  schemas:
    TestDTO:
      required:
        - choice
      type: object
      properties:
        choice:
          description: Choice description
          allOf:
            - $ref: '#/components/schemas/TestEnum'
    TestEnum:
      type: string
      enum:
        - One
        - Two
        - Three

I then use the Swagger Parser v3 to parse (and print afterwards) the above definition (embedded in a complete OpenAPI document).

        String apiDefinition;
        try (Reader apiDefinitionReader = new InputStreamReader(new ClassPathResource("test.yaml").getInputStream())) {
            apiDefinition = CharStreams.toString(apiDefinitionReader);
        }

        OpenAPIV3Parser parser = new OpenAPIV3Parser();
        ParseOptions options = new ParseOptions();
        options.setResolve(true);
        options.setResolveCombinators(true);
        options.setResolveFully(true);
        options.setFlatten(true);
        OpenAPI openAPI = parser.readContents(apiDefinition, /* auths: */ null, options).getOpenAPI();

        System.out.println(Yaml.mapper().writeValueAsString(openAPI));

The output is then as follows:

openapi: 3.0.1
info:
  title: Test
  description: Description
  version: "1"
servers:
- url: /
tags:
- name: Test
  description: Test tag description
paths:
  /do-something:
    post:
      tags:
      - Test
      description: Do something operation description
      operationId: do-something
      requestBody:
        content:
          application/json:
            schema:
              required:
              - choice
              type: object
              properties:
                choice: {}
      responses:
        "200":
          description: Do something operation result description
components:
  schemas:
    TestDTO:
      required:
      - choice
      type: object
      properties:
        choice: {}
    TestEnum:
      type: string
      enum:
      - One
      - Two
      - Three

It seems the the parser cannot process the allOf construct correctly.

@frantuma frantuma added this to the M2 milestone May 14, 2020
@dhanasekar416
Copy link

dhanasekar416 commented May 18, 2020

Hi @frantuma / @gracekarina ,

I had raised an issue with context similar to this issue. Can you please check that issue?

@frantuma frantuma modified the milestones: M2, M3 Jun 2, 2020
gracekarina added a commit that referenced this issue Jun 19, 2020
gracekarina added a commit that referenced this issue Jun 19, 2020
Fix and test for Parser cannot process 'allOf' correctly - issue #1367
@gracekarina
Copy link
Contributor

Hi @ronny-stauffer we have merged a fix for this issue, please let us know if this keeps happening. Thanks for reporting the issue!.

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

No branches or pull requests

4 participants