swagger-api / swagger-api/swagger-parser

ResolveFully ignores properties in schema with combinators

Open
#1,802 0 comments 0 reactions 1 assignee View on GitHub

@gracekarina is already working on this.

Since Sep 20, 2022.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Parser version:

2.1.2

Spec:

openapi: "3.0.0"
info:
  version: 1.0.0
  title: 0001_allOffProps

paths:
  /sample_resource:
    post:
      operationId: createResOne
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/create_res_one"
      responses:
        '201':
          description: Ok
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/standard_response_res_one"
components:
  schemas:
    standard_response_result:
      properties:
        result:
          type: object
          properties:
            status:
              type: boolean
            http_code:
              type: integer
            errors:
              type: array
              items:
                $ref: '#/components/schemas/standard_error'
            info:
              type: string
            trace_id:
              type: string
            num_elements:
              type: integer
          required:
            - status
            - http_code
            - trace_id
    standard_error:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
    standard_response_res_one:
      type: object
      allOf:
        - $ref: '#/components/schemas/standard_response_result'
      properties:
        data:
          properties:
            name:
              type: string
    create_res_one:
      type: object
      properties:
        name:
          type: string

Code:

        ParseOptions parseOptions = new ParseOptions();
        parseOptions.setResolveFully(true);
        OpenAPI openAPI = new OpenAPIV3Parser().read("api.yaml" + fileName, null, parseOptions);

Expected result:

The schema standard_response_res_one has 2 properties: data and result

Current result:

The schema standard_response_res_one only has the result property

Investigation about the issue cause:

After debugging the issue seems that in the class ResolverFully we need to add the properties of the composedSchema to the result schema (https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java#L405)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.