Skip to content

[Bug]: Cascading $refs are not resolved fully for additionalProperties #2218

@nicolaideffremo

Description

@nicolaideffremo

Description

When resolving $ref in an array in additionalProperties cascading $refs are not resolved. I attached an example with file references.

Affected Version

2.1.31

Steps to Reproduce

openapi: 3.0.3
info:
  description: A service with remote models
  version: 1.0.o
  title: A service
paths:
  /foo:
    get:
      description: Get Flag of flags
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: './model.yaml#/components/schemas/FlagsOfFlags'
openapi: 3.0.3
info:
  description: Description
  version: 1.0.0
  title: A title
paths: {}
components:
  schemas:
    Flag:
      type: object
      description: Active flag 
      properties:
        isActive:
          type: boolean
    Flags:
      type: object
      description: Map of flags 
      additionalProperties:
        type: array
        items:
          $ref: '#/components/schemas/Flag'
    FlagsOfFlags:
      type: object
      description: Flag of flag configuration
      additionalProperties:
        type: array
        items:
          $ref: '#/components/schemas/Flags'

Parsing with the code below reproduces the behavior.

        ParseOptions options = new ParseOptions();
        options.setResolve(true);
        SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpec, authorizationValues, options);

Expected Behavior

Have all $refs resolved in the parse result, such that they are available in #/components/

Actual Behavior

Only the FlagsOfFlags is resolved, the others are not.

Additional Context

Further investigation shows, that this branch in ExternalRefProcessor#processRefToExternalSchema prevents the wrong $ref from being blank. It should look at the items.

I can provide a PR if desired.

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions