Filter ignores some $refs
See original GitHub issueHello! I wanted to use the openapi-filter to remove some internal headers from our public openapi specifications. Unfortunately, it doesn’t seem to fully work.
An example:
openapi: 3.0.2
info:
  title: Swagger Petstore - OpenAPI 3.0
  description: omit
  termsOfService: 'http://swagger.io/terms/'
  contact:
    email: apiteam@swagger.io
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
  version: 1.0.5
servers:
  - url: /api/v3
paths:
  /pet:
    post:
      tags:
        - pet
      summary: Add a new pet to the store
      description: Add a new pet to the store
      operationId: addPet
      parameters:
        - $ref: '#/components/parameters/InternalHeader'
        - $ref: '#/components/parameters/OtherInternalHeader'
        - in: header
          name: X-ThirdInternalHeader
          schema:
            type: string
          required: true
          x-internal: true
      requestBody:
        description: Create a new pet in the store
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Pet'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        '405':
          description: Invalid input
components:
  parameters:
    InternalHeader:
      in: header
      name: X-InternalHeader
      schema:
        type: string
      required: true
      x-internal: true
    OtherInternalHeader:
      in: header
      name: X-OtherInternalHeader
      schema:
        type: string
      required: true
      x-internal: true
  schemas:
    Pet:
      required:
        - name
        - photoUrls
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 10
      xml:
        name: pet
You can see there are three headers (InternalHeader, OtherInternalHeader & ThirdInternalHeader). After running the openapi-filter the result looks like this:
... omitted because irrelevant
paths:
  /pet:
    post:
      tags:
        - pet
      summary: Add a new pet to the store
      description: Add a new pet to the store
      operationId: addPet
      parameters:
        - $ref: "#/components/parameters/OtherInternalHeader"
...
components:
  parameters: {}
... omitted because irrelevant
In the end all the parameter definitions are removed but the reference to ONE of the two headers is still there.
Issue Analytics
- State:
 - Created 2 years ago
 - Comments:7 (3 by maintainers)
 
Top Results From Across the Web
Understanding why git-filter-branch is not cleaning my history
The refs that git filter-branch reports as unchanged did not have a file named terra/fixtures.go anywhere in their histories.
Read more >preserve git notes · Issue #22 · newren/git-filter-repo - GitHub
I am new to Git scripting - how do i ignore commits with no notes ? ... tail -n +2 .git/filter-repo/commit-map | git...
Read more >git-filter-branch Documentation - Git
If you have any grafts or replacement refs defined, running this command will make them permanent. WARNING! The rewritten history will have different...
Read more >Ubuntu Manpage: git-filter-branch - Rewrite branches
If you have any grafts or replacement refs defined, running this command will make them permanent. WARNING! The rewritten history will have different...
Read more >git-filter-repo — Debian testing
git-filter-repo - Rewrite repository history ... •Rewriting history may delete some refs (e.g. branches that only had files that you wanted ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Will try and publish today.
@MikeRalphson Thanks for the merge! When will this be released to npm? I would need the changes for a project.