Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Combining multiple files into one keeps references to some api files #87

Open
@apoza

Description

@apoza

Problem

I have an API splitted in several files and I have used swagger-cli to combine those files into one (to use that file in API consumer services/applications)
When any API file is referenced using $ref that file is exported (included) in the new API file as component (that's good). But those files that are referenced without using $ref are exported (included in the bundled file) keeping the reference to the file.

Example

Let's suppose that we have OpenApi.yaml that has this endpoint deffinition

 [...]
 /offering:
    post:
      [...]
      requestBody:
        description: This is an offering
        required: true
        content:
          application/json:
            schema:
              $ref: ./Offering.yaml
 [...]

This is Offering.yaml

title: Offering
description: Interface of offering requests
oneOf:
  - $ref: ./LocalOffering.yaml
  - $ref: ./InternationalOffering.yaml
discriminator:
  propertyName: type
  mapping:
    local: ./LocalOffering.yaml
    international: ./InternationalOffering.yaml

When I combine the API files (executing: swagger-cli bundle OpenApi.yaml --outfile CombinedApi.yaml --type yaml) this is the outcome (CombinedApi.yaml):

 [...]
Offering:
      title: Offering
      description: Interface of offering requests
      oneOf:
        - $ref: '#/components/schemas/LocalOffering'
        - $ref: '#/components/schemas/InternationalOffering'
      discriminator:
        propertyName: type
        mapping:
          local: ./LocalOffering.yaml
          international: ./InternationalOffering.yaml
 [...]

As we can see the discriminator.mapping.local and discriminator.mapping.international keeps files references. That means that we need those files so the combination in one file is not valid

Expected behavior

I would expect than those files referenced without using $ref would be exported in a way (maybe the same way that $ref ones) that doesn't keep the reference to the files.

Expected outcome:

 [...]
Offering:
      title: Offering
      description: Interface of offering requests
      oneOf:
        - $ref: '#/components/schemas/LocalOffering'
        - $ref: '#/components/schemas/InternationalOffering'
      discriminator:
        propertyName: type
        mapping:
          local: '#/components/schemas/LocalOffering'
          international: '#/components/schemas/InternationalOffering'
 [...]

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