Code Monkey home page Code Monkey logo

pb33f / openapi-changes Goto Github PK

View Code? Open in Web Editor NEW
135.0 1.0 11.0 22.03 MB

The world's sexiest OpenAPI breaking changes detector. Discover what changed between two OpenAPI specs, or a single spec over time. Supports OpenAPI 3.1, 3.0 and Swagger

Home Page: https://pb33f.io/openapi-changes/

License: Other

Go 59.39% CSS 7.68% JavaScript 1.77% HTML 1.20% TypeScript 29.78% Makefile 0.03% Dockerfile 0.15%
diff openapi openapi3 swagger oas3 openapi-generator openapi-repo openapi-spec openapi-specification

openapi-changes's Introduction

logo

discord GitHub downloads npm Docker Pulls

OpenAPI Changes

The world's sexiest OpenAPI diff tool.

We will get to the sexy part in a moment, but in a nutshell openapi-changes allows you to see and explore what has changed with your OpenAPI Specification, between a single change, or for all time!

Explore OpenAPI change history using a terminal or a browser, you decide which experience suits you. Perfect for individual use, or in a CI/CD pipeline for automation.

This is an early tool and is active, daily development

How is it the 'sexiest'?

Have you ever seen an OpenAPI diff report look like this?

What about a terminal UI that does the same?


Documentation

See all the documentation at https://pb33f.io/openapi-changes/


Are you ready to try it out?

Install using homebrew tap

brew install pb33f/taps/openapi-changes

Install using npm or yarn

npm i -g @pb33f/openapi-changes

If you prefer yarn (recommended)

yarn global add @pb33f/openapi-changes

Install using cURL

curl -fsSL https://pb33f.io/openapi-changes/install.sh | sh 

Install/run using Docker

docker pull pb33f/openapi-changes

To run, mount the current working dir to the container like so:

docker run --rm -v $PWD:/work:rw pb33f/openapi-changes summary . sample-specs/petstorev3.json

The console cannot run via docker.


Check out all the docs at https://pb33f.io/openapi-changes/

openapi-changes's People

Contributors

daveshanley avatar jacobm-splunk avatar lasnef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

openapi-changes's Issues

License file

Hi and thanks for amazing tool!
It's really good, but what license that?
I sow that libopenapi is MIT

Overall Change Pie Chart Counter not ok

API diff counter pie cournter is wrong when 100 of the changes are breaking

it display as below
image

with the counter beeing
image

we have a clear repartion of the changes 1 third added , 2 third remove that is displayed correctly on the chart

however for the overall changes the percentage are wrong , it let us think that 50 % are breaking vs this is 100%

How to reproduce :
do API diff on https://github.com/oasis-tcs/odata-openapi/blob/main/examples/odata-rw-v3.openapi3.json

How long is a summary between to spec suppose to take?

Been working on a generated GitHub client based on their OpenAPI spec, and I've been looking for a tool to generate a meaningful message when a new version of a client is generated.

To test your tool I'm currently running this command, and it's been 5 and a half hours at this point:

docker run --rm -v $PWD:/work:rw pb33f/openapi-changes summary example/api.github.com.yaml https://raw.githubusercontent.com/github/rest-api-description/main/descriptions-next/api.github.com/api.github.com.yaml

Online version broken after a wrong file input

given 2 files one is correct one not correct

the UI shoot an error (fair)

the fixing the issue and replacing the file via another upload ,

The spinner spin forever and never finish

sample fails (cf $ref , PetPo vs PetPot )

{
    "openapi": "3.1.0",
    "info": {
        "title": "this is the title",
        "description": "this is the description",
        "version": "1.0"
    },
    "servers": [
        {
            "url": "https://api.server.test/v1"
        }
    ],
    "paths": {
        "/test": {
            "get": {
                "operationId": "getTest",
                "responses": {
                    "200": {
                        "description": "testOK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/PetPo"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "PetPot": {
                "type": "object",
                "required": [
                    "tagProp"
                ],
                "properties": {
                    "tagProp": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "example": [
                            "Joe",
                            "Bye"
                        ]
                    }
                },
                "example": {
                    "tagProp": [
                        "TODAY",
                        "NOW"
                    ]
                }
            },
            "Yo": {
                "type": "number"
            },
            "OK": {
                "$ref": "#/components/schemas/Yo"
            }
        }
    }
}

[Bug] ordering of field should not matter

here the only difference is the field ordering (eq , neq )

image

    properties:
      field:
        type: string
        description: |
          Label of the parameter to filter on. 
      in:
        $ref: '#/components/schemas/operatorArray'
      nin:
        $ref: '#/components/schemas/operatorArray'
      eq:
        $ref: '#/components/schemas/operator'
      neq:
        $ref: '#/components/schemas/operator'
      le:
        $ref: '#/components/schemas/operator'
      lt:
        $ref: '#/components/schemas/operator'
      ge:
        $ref: '#/components/schemas/operator'
      gt:
        $ref: '#/components/schemas/operator'

vs

   properties:
      field:
        type: string
        description: |
          Label of the parameter to filter on.
      in:
        $ref: '#/components/schemas/operatorArray'
      nin:
        $ref: '#/components/schemas/operatorArray'
      le:
        $ref: '#/components/schemas/operator'
      lt:
        $ref: '#/components/schemas/operator'
      ge:
        $ref: '#/components/schemas/operator'
      gt:
        $ref: '#/components/schemas/operator'
      eq:
        $ref: '#/components/schemas/operator'
      neq:
        $ref: '#/components/schemas/operator'

Errors while trying to use openapi-changes

Hello,
I made changes to openapi-changes to allow local (-x) and remote (-y) refs. Will raise a PR soon.
I was testing using two simple openapi files each including another file (old/new_blah.json) via $ref.
GitHub didn't let me upload json files, hence renamed as .txt

$ diff old_test_openapi.json new_test_openapi.json
18c18
< "$ref": "old_blah.json"

                    "$ref": "new_blah.json"

####################

$ diff old_blah.json new_blah.json
7c7
< "type": "string",

        "type": "int",

Here are my results. I feel the errors are coming from openapilib, or if I'm doing something not right.

  1. openapi-changes report -x -y old_test_openapi.json new_test_openapi.json
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x14949b4]

goroutine 1 [running]:
github.com/pb33f/libopenapi/what-changed/reports.CreateOverallReport(0x0)
/Users/XYZ/go/pkg/mod/github.com/pb33f/[email protected]/what-changed/reports/summary.go:26 +0x34
github.com/pb33f/openapi-changes/cmd.createReport(...)
/Users/XYZ/generated_openapi/openapi-changes/cmd/report.go:349
github.com/pb33f/openapi-changes/cmd.runLeftRightReport({0x7ff7bfeff4d6, 0x15}, {0x7ff7bfeff4ec, 0x15}, 0x4?, 0x19b97a0?, 0x0?, 0x0?)
/Users/XYZ/generated_openapi/openapi-changes/cmd/report.go:345 +0x659
github.com/pb33f/openapi-changes/cmd.GetReportCommand.func1(0xc0001d8200?, {0xc000134c40, 0x2, 0x16b88d3?})
/Users/XYZ/generated_openapi/openapi-changes/cmd/report.go:197 +0xb4d
github.com/spf13/cobra.(*Command).execute(0xc000004900, {0xc000134c00, 0x4, 0x4})
/Users/XYZ/go/pkg/mod/github.com/spf13/[email protected]/command.go:916 +0x87c
github.com/spf13/cobra.(*Command).ExecuteC(0x1ed2580)
/Users/XYZ/go/pkg/mod/github.com/spf13/[email protected]/command.go:1044 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
/Users/XYZ/go/pkg/mod/github.com/spf13/[email protected]/command.go:968
github.com/pb33f/openapi-changes/cmd.Execute({0x16b95ac?, 0x10013f0?}, {0x16b95ac?, 0x16c2b29?}, {0xc00002c840?, 0xc0000061a0?})
/Users/XYZ/generated_openapi/openapi-changes/cmd/root.go:52 +0xb0
main.main()
/Users/XYZ/generated_openapi/openapi-changes/openapi-changes.go:26 +0x105

  1. openapi-changes summary -x -y old_test_openapi.json new_test_openapi.json

@@@@@@@ @@@@@@@ @@@@@@ @@@@@@ @@@@@@@@

openapi-changes version: latest | compiled: 2023-09-28 15:33:17 PDT

INFO printing summary

This is not showing any diffs, let alone breaking changes.

Just to let you know, the following worked perfectly:
openapi-changes console -x -y https://github.com/pb33f/openapi-changes/blob/main/sample-specs/petstorev3.json

old_test_openapi.json.txt
new_test_openapi.json.txt
new_blah.json.txt
old_blah.json.txt

[feature] queryParameter renaming should be mentionned as warning

given an endpoint with a query parameter

parameters:
- $ref: '#/components/parameters/query_calibrationResultId'

given

query_calibrationResultId:
  name: calibrationResultId
  description: |
    Calibration result in which the resource(s) will be queried.
  in: query
  schema:
    type: string
  example: '1234'
  required: true

changing the parameterName (for instance changing here query_calibrationResultI to queryCalibrationResultId,
but keeping the same name shoud not be detected as special : meaning it s a change but not a breaking change , just renaming

currently it is a added / removed

openAPI change can be heavily used in case of refactoring ...

could be hard to detect with may be some edge cased, @daveshanley do not hesitate to close it if not applicable

Markdown output

Been using this tool to generate changes for automated PR's like this one: php-api-clients/github-root#438
It doesn't look pretty but it pains a clear enough picture. Would you be open for a PR adding a markdown as an output?

Feature request: Improvement for in-command help

If I run openapi-changes summary it shows me a few nice examples of how to use it, but it neither has a link to the online docs showing the flags (-n, --no-logo, etc.) nor any inline help showing the potential options.

It would be nice if:

  • Running openapi-changes -? or openapi-changes --help would display a fairly standard help dialog, even if it was the same as just running it without any switches. It's not obvious on how to get help.
  • Running openapi-changes summary -? would not only show the examples, but the list of available flags.

I think the colorful UI is pretty cool, but from an online help perspective, I think some of the classic help mechanisms like other commands (git, kubectl, etc.) have where the options are explained in a complete list might be interesting.

Incorrect "cannot resolve reference..." error

I'm running the latest 0.0.21 release on windows, comparing two swagger files in summary mode like so: .\bin\openapi-changes.exe summary .\v1_latest.json .\v2_latest.json
the command prints the following:

openapi-changes version: 0.0.21 | compiled: 2023-04-20T15:53:45Z

  ERROR   Stopped: Error thrown when comparing: cannot resolve reference `#/components/schemas/ResourceList[InsuranceResource]`, it's missing: $.components.schemas.ResourceList[InsuranceResource] [36847:13]


fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
github.com/pb33f/openapi-changes/model.SendProgressError(...)
        /home/runner/work/openapi-changes/openapi-changes/model/progress.go:43
github.com/pb33f/openapi-changes/git.BuildCommitChangelog({0xc00a9adba0, 0x2, 0xc0000b9bb0?}, 0x1?, 0x1?)
        /home/runner/work/openapi-changes/openapi-changes/git/read_local.go:167 +0xc45
github.com/pb33f/openapi-changes/cmd.runLeftRightSummary({0xc0000240c0, 0x10}, {0xc0000240f0, 0x10}, 0x0?, 0x0?)
        /home/runner/work/openapi-changes/openapi-changes/cmd/summary.go:211 +0x5ec
github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1(0xc000004600?, {0xc000112220, 0x2, 0x2?})
        /home/runner/work/openapi-changes/openapi-changes/cmd/summary.go:162 +0x53b
github.com/spf13/cobra.(*Command).execute(0xc000004600, {0xc0001121c0, 0x2, 0x2})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x117d640)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:968
github.com/pb33f/openapi-changes/cmd.Execute({0xdc2194?, 0x0?}, {0xdc8960?, 0x0?}, {0xdc4250?, 0xc00006c000?})
        /home/runner/work/openapi-changes/openapi-changes/cmd/root.go:48 +0xaa
main.main()
        /home/runner/work/openapi-changes/openapi-changes/openapi-changes.go:26 +0x10e

goroutine 18 [chan send]:
github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1.1(0xc00011c060, 0xc00011c0c0)
        /home/runner/work/openapi-changes/openapi-changes/cmd/summary.go:91 +0x4b9
created by github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1
        /home/runner/work/openapi-changes/openapi-changes/cmd/summary.go:161 +0x50c

Based on the line number I believe it is erroring on the 2nd file which has the correct schema and reference path as shown:
Screenshot 2023-04-25 105234

Let me know if you need additional information.

Const changes aren't correctly detected

(unsure whether this is an issue better filed here or with https://github.com/pb33f/libopenapi - feel free to redirect!)

We're trying to use openapi-changes to detect breaking spec changes to our production API.

We're not seeing changes to const values detected at all (let alone as "breaking"). I've put together a MWE to demonstrate the issue we're seeing (https://gist.github.com/srir/8513874d960a2fd5fbb380f484e4ffc0)

Expected:

  • openapi-changes summary spec_prod.json spec_new.json detects and reports a difference
  • note: the difference is subtle (a change to the const value in the type property for each of ResourceNotFoundError and FeatureNotAvailableError)

Actual:

  • no differences are detected; openapi-changes summary spec_prod.json spec_new.json exits with the following, and exit code 0:
openapi-changes version: 0.0.42 | compiled: 2023-09-09T15:03:00Z


 INFO  printing summary

Issue when running specs comparison using latest docker image - v0.0.54

Hi Team,

We are running following command in Azure Devops pipeline to compare specs changes. And task gets timed out when using latest docker image.

command -
docker run --rm -v "$PWD`:/specs`:rw" pb33f/openapi-changes summary /specs/.original.json /specs/schema.json
Task type = Powershell

Output -
image

`-n` styling command fails with file-to-file comparison

Running openapi-changes summary to compare two files works great:

openapi-changes summary ./schema.json ./test-schema.json

In tests, this yields:

@@@@@@@   @@@@@@@   @@@@@@   @@@@@@   @@@@@@@@
@@@@@@@@  @@@@@@@@  @@@@@@@  @@@@@@@  @@@@@@@@
@@!  @@@  @@!  @@@      @@@      @@@  @@!
!@!  @!@  !@   @!@      @!@      @!@  !@!
@!@@!@!   @!@!@!@   @!@!!@   @!@!!@   @!!!:!
!!@!!!    !!!@!!!!  !!@!@!   !!@!@!   !!!!!:
!!:       !!:  !!!      !!:      !!:  !!:
:!:       :!:  !:!      :!:      :!:  :!:
 ::        :: ::::  :: ::::  :: ::::   ::
 :        :: : ::    : : :    : : :    :


openapi-changes version: 0.0.20 | compiled: 2023-03-30T14:51:42Z


 INFO  printing summary
└─┬Paths
  └─┬/banking/v1/products
    └─┬GET
      └─┬Responses
        └─┬200
          └─┬application/json
            └─┬Schema
              └─┬Schema
                └──[M] $ref (180:18)❌

Date: 04/14/23 | Commit: New: ./test-schema.json, Original: ./schema.json
Document Element | Total Changes | Breaking Changes
paths            | 1             | 1
❌ 1 Breaking changes out of 1

  ERROR   breaking changes discovered

If I add the -n parameter to turn off coloring, it seems to want to try doing a git-based diff and ignores the files.

openapi-changes summary -n ./schema.json ./test-schema.json

This yields...

@@@@@@@   @@@@@@@   @@@@@@   @@@@@@   @@@@@@@@
@@@@@@@@  @@@@@@@@  @@@@@@@  @@@@@@@  @@@@@@@@
@@!  @@@  @@!  @@@      @@@      @@@  @@!
!@!  @!@  !@   @!@      @!@      @!@  !@!
@!@@!@!   @!@!@!@   @!@!!@   @!@!!@   @!!!:!
!!@!!!    !!!@!!!!  !!@!@!   !!@!@!   !!!!!:
!!:       !!:  !!!      !!:      !!:  !!:
:!:       :!:  !:!      :!:      :!:  :!:
 ::        :: ::::  :: ::::  :: ::::   ::
 :        :: : ::    : : :    : : :    :


openapi-changes version: 0.0.20 | compiled: 2023-03-30T14:51:42Z

starting work.
Building original model for commit 04dd12

...and then it hangs, for minutes. It never completes so I have to ^C kill it.

Support custom policy

I think there is a much needed feature,
Use a custom policy for the diff with options like

  • Exclude breaking change
  • Include breaking change

this way an organization can use the product how he sees fit.

First I would like to see if this idea is approved,

file name: pb.yaml (shorthand for pb33f)
Content:

ruleset:
  - β€œbreaking-changes”:
      exclude_operations_with_extension: β€œx-foo”,
      include_operations_with_extension: β€œx-bar”

[feature Request] level for breaking change be customizable

@daveshanley there are 2 levels that could be applied

  1. identify each rules via an indentifier and have the capability to have flag : off; info, warning, breaking

  2. capability for end user to add more rules leveraging, but this is munch more challenging

i think 1 one be good enough with a good catalog of breaking change detection , it should make the deal

In HTML diff editor, displaying unchanged paths due to referenced schema changed

Hello there!
I've noticed a behavior in the HTML report, When an operation parameter includes a schema reference and the schema itself is modified, both the path, operation and parameters are rendered in the diff editor tree.

For example, consider the following operation parameter:
image

If the schema is altered, the tree is displayed as follows:
image

The paths, operations, and parameters are rendered, although they are not clickable or altered. While this behavior might not be problematic with small OpenAPI specs, it becomes cumbersome and confusing when a schema is referenced across multiple operation parameters.

Is this behavior expected?
Thanks! :)

renaming properties is not detected as (breaking) change

Hi,

first thanks for this awesome project! When using openapi-changes I noticed that renaming properties are not detected at changes. Removal or changing types is detected correctly.

Example to reproduce:

openapi-changes summary original.yaml changed.yaml

original.yaml

openapi: 3.1.0
paths:
  /api/header:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: string

changed.yaml

openapi: 3.1.0
paths:
  /api/header:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  text: # breaking change!
                    type: string

output: SUCCESS No changes detected

should be: ERROR breaking changes discovered

Open API Changes , install not working on Windows

here is a diff between vacuum that works and open api change
it should leverage tar that maintains executable statement rather than relying on chmod that looks not ok

PS D:\tmp\developer-portal> npm i -g @pb33f/openapi-changes
npm ERR! code 1
npm ERR! path C:\Users\XXX\AppData\Roaming\npm\node_modules@pb33f\openapi-changes
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node ./npm-install/postinstall.js
npm ERR! fetching from URL https://github.com/pb33f/openapi-changes/releases/download/v0.0.53/openapi-changes_0.0.53_windows_x86_64.zip
npm ERR! Error: ENOENT: no such file or directory, chmod './bin/openapi-changes'
npm ERR! at Module.chmodSync (node:fs:1916:3)
npm ERR! at install (file:///C:/Users/XXX/AppData/Roaming/npm/node_modules/@pb33f/openapi-changes/npm-install/postinstall.js:54:14)
npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
npm ERR! errno: -4058,
npm ERR! syscall: 'chmod',
npm ERR! code: 'ENOENT',
npm ERR! path: './bin/openapi-changes'
npm ERR! }

image

Error message Exit Status 128 : not clear

given the command line
PS D:\code\repos\developer-portal> D:\tools\openapi-changes.exe report . .\documentations\reference-data\component-descriptor.yml
ERROR exit status 128
Error: exit status 128

Does it need a fully-resolved schema?

Hello,
This looks awesome!

I have an OAS 3.x openapi.json file which has references, using "$ref", to small, external files like email.json, CC.json etc.
Assume there is a breaking change in the referred-to file like CC.json.
Can the tool be given the old and new (modified) CC.json?
Or, does it only take openapi.json files as input?

The reason I'm asking is if it's the latter, wonder if the line numbers point to those in CC.json file, or the fully exploded (dereferenced) openapi.json, which makes it difficult to point the line # back to CC.json.

Please let me know if my question didn't make sense.
Thanks so much!

Deadlock Issue with Goroutines in openapi-changes Tool When Comparing OpenAPI Specifications

Hello,

First of all, thank you for your project. 🀠
I've encountered an issue with the openapi-changes tool when trying to compare two OpenAPI specifications. Specifically, when I run the comparison with npx, I encounter a problem related to goroutines, which leads to a deadlock error. This issue also manifests in my GitLab CI pipeline, presenting the same error in the logs.

@@@@@@@   @@@@@@@   @@@@@@   @@@@@@   @@@@@@@@
@@@@@@@@  @@@@@@@@  @@@@@@@  @@@@@@@  @@@@@@@@
@@!  @@@  @@!  @@@      @@@      @@@  @@!
!@!  @!@  !@   @!@      @!@      @!@  !@!
@!@@!@!   @!@!@!@   @!@!!@   @!@!!@   @!!!:!
!!@!!!    !!!@!!!!  !!@!@!   !!@!@!   !!!!!:
!!:       !!:  !!!      !!:      !!:  !!:
:!:       :!:  !:!      :!:      :!:  :!:
 ::        :: ::::  :: ::::  :: ::::   ::
 :        :: : ::    : : :    : : :    :

openapi-changes version: 0.0.55 | compiled: Mon, 26 Feb 2024 21:16:51 UTC

β–€  Building original model for commit b5a4cb
  SPEC   extracted 2 commits from history                                                                                                            
└─┬Paths
  β”œβ”€β”€[-] path (19:3)❌ 
  β”œβ”€β”€[-] path (48:3)❌ 
  β”œβ”€β”€[+] path (19:3)
  └──[+] path (48:3)

Date: 03/06/24 | Commit: New: tmp/openapi.yaml, Original: oas/cats.yaml
Document Element | Total Changes | Breaking Changes
paths            | 4             | 2

❌  2 Breaking changes out of 4
 INFO  Removals: 2
 INFO  Additions: 2
 INFO  Breaking Removals: 2
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1(0x40002f0608, {0x40002a05e0, 0x2, 0x887a84?})
        D:/a/openapi-changes/openapi-changes/cmd/summary.go:229 +0x744
github.com/spf13/cobra.(*Command).execute(0x40002f0608, {0x40002a0580, 0x2, 0x2})
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x128d4c0)
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/pb33f/openapi-changes/cmd.Execute({0xc2682c?, 0x19?}, {0xc30c40?, 0x8962a8?}, {0x400029e640?, 0x40000021c0?})
        D:/a/openapi-changes/openapi-changes/cmd/root.go:51 +0xa0
main.main()
        D:/a/openapi-changes/openapi-changes/openapi-changes.go:29 +0x184

goroutine 17 [select]:
github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1.1(0x40002fc060, 0x40002fc0c0)
        D:/a/openapi-changes/openapi-changes/cmd/summary.go:85 +0x390
created by github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1 in goroutine 1
        D:/a/openapi-changes/openapi-changes/cmd/summary.go:212 +0x6cc

🧐 Steps to Reproduce:
Use the following Dockerfile to set up the environment and replicate the issue locally:

FROM node:20.11
WORKDIR /app
COPY . . 
CMD ["bash", "-c", "npx @pb33f/openapi-changes summary openapi.yaml tmp/openapi.yaml"]
# (docker build --no-cache -t oas-changes . && docker run -it --attach STDOUT --attach STDERR oas-changes)

Additional Information:

  • openapi-changes version: 0.0.55
  • Node version: 20.11 (as used in the Dockerfile)
  • The issue occurs both locally and in a GitLab CI environment.

This deadlock issue prevents successful comparison of OpenAPI specifications and affects the integration in CI pipelines. Any insights or fixes for this problem would be greatly appreciated.

Thank you!

[crash] using console mode

leveraging the latest version got this stack

Notice running vaccum on each file does not crash ...

documentations\datamart-reports> D:\tmp\openapi-changes.exe console .\component-descriptor.yml .\component-descriptor2.yml

@@@@@@@   @@@@@@@   @@@@@@   @@@@@@   @@@@@@@@
@@@@@@@@  @@@@@@@@  @@@@@@@  @@@@@@@  @@@@@@@@
@@!  @@@  @@!  @@@      @@@      @@@  @@!
!@!  @!@  !@   @!@      @!@      @!@  !@!
@!@@!@!   @!@!@!@   @!@!!@   @!@!!@   @!!!:!
!!@!!!    !!!@!!!!  !!@!@!   !!@!@!   !!!!!:
!!:       !!:  !!!      !!:      !!:  !!:
:!:       :!:  !:!      :!:      :!:  :!:
 ::        :: ::::  :: ::::  :: ::::   ::
 :        :: : ::    : : :    : : :    :


openapi-changes version: 0.0.55 | compiled: Mon, 26 Feb 2024 21:16:51 UTC

  DONE   starting console...


panic: reflect: call of reflect.Value.Elem on slice Value

goroutine 1 [running]:
reflect.Value.Elem({0xd755c0?, 0xc001e870a8?, 0x0?})
        C:/hostedtoolcache/windows/go/1.22.0/x64/src/reflect/value.go:1277 +0x195
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc002010d00, {0xdfb860, 0xc001e870a0})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:59 +0x40af
github.com/pb33f/openapi-changes/tui.DigIntoObject[...](0xc002010c80, 0xc002010d00, {0xdfb860, 0xc001c35188?, 0xdfb860?})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:311 +0xf6
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc002010c80, {0xdfb960, 0xc001c35180})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:144 +0x326f
github.com/pb33f/openapi-changes/tui.DigIntoObject[...](0xc002010b00, 0xc002010c80, {0xdfb960, 0xc002154300?, 0xdfb960?})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:311 +0x127
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc002010b00, {0xdfb960, 0xc0021542a0})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:109 +0x389f
github.com/pb33f/openapi-changes/tui.BuildTreeMapNode({0xdd3320?, 0xc001c35028?, 0x0?}, 0xc002010a80)
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:294 +0x1fe
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc002010880, {0xdfb960, 0xc001c34fc0})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:171 +0x2ecc
github.com/pb33f/openapi-changes/tui.DigIntoObject[...](0xc002010800, 0xc002010880, {0xdfb960, 0xc000dbb268?, 0xdfb960?})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:311 +0x127
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc002010800, {0xdfbbe0, 0xc000dbb260})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:109 +0x389f
github.com/pb33f/openapi-changes/tui.BuildTreeMapNode({0xdd3200?, 0xc000f22c28?, 0x0?}, 0xc002010780)
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:294 +0x1fe
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc002010580, {0xdfbf60, 0xc000f22c00})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:213 +0x250c
github.com/pb33f/openapi-changes/tui.BuildTreeMapNode({0xdd32c0?, 0xc001e87048?, 0x0?}, 0xc0022bf300)
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:294 +0x1fe
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc0022bf300, {0xdfbfe0, 0xc001e87040})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:164 +0x2f45
github.com/pb33f/openapi-changes/tui.DigIntoObject[...](0xc0003cbb00, 0xc0022bf300, {0xdfbfe0, 0xc0003cbba8?, 0xdfbfe0?})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:311 +0x113
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc0003cbb00, {0xdfc1e0, 0xc0003cbb80})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:149 +0x31b9
github.com/pb33f/openapi-changes/tui.DigIntoObject[...](0xc0003cb680, 0xc0003cbb00, {0xdfc1e0, 0xc000a20008?, 0x0?})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:311 +0x127
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc0003cb680, {0xdfc260, 0xc000a20000})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:84 +0x3cdf
github.com/pb33f/openapi-changes/tui.BuildTreeMapNode({0xdd3260?, 0xc001692968?, 0x0?}, 0xc0003cb580)
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:294 +0x1fe
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc0003cb080, {0xdfc860, 0xc001692960})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:232 +0x214d
github.com/pb33f/openapi-changes/tui.DigIntoObject[...](0xc0003cab00, 0xc0003cb080, {0xdfc860, 0xc0007de010?, 0xdfc860?})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:311 +0xff
github.com/pb33f/openapi-changes/tui.buildTreeNode(0xc0003cab00, {0xdfc660, 0xc0007de000})
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:80 +0x3d93
github.com/pb33f/openapi-changes/tui.BuildTreeModel({0x12e2568?, 0xc00087e3c0?}, 0xc0007de000)
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:35 +0xbf
github.com/pb33f/openapi-changes/tui.BuildTreeView(0xc000598750?)
        D:/a/openapi-changes/openapi-changes/tui/build_tree.go:20 +0x3a
github.com/pb33f/openapi-changes/tui.BuildApplication({0xc000e181c0, 0x2, 0x2}, {0x12ceb84, 0x6})
        D:/a/openapi-changes/openapi-changes/tui/main_console.go:24 +0x66
github.com/pb33f/openapi-changes/cmd.runLeftRightCompare({0xc000024240, 0x1a}, {0xc000024280, 0x1b}, 0xc00029e060, 0xc00029e0c0, {0x0, 0x0}, 0x1)
        D:/a/openapi-changes/openapi-changes/cmd/console.go:382 +0x810
github.com/pb33f/openapi-changes/cmd.init.0.GetConsoleCommand.func1(0xc00014c308, {0xc000292240, 0x2, 0xf2ffd0?})
        D:/a/openapi-changes/openapi-changes/cmd/console.go:248 +0x9af
github.com/spf13/cobra.(*Command).execute(0xc00014c308, {0xc0002921e0, 0x2, 0x2})
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x194e380)
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/pb33f/openapi-changes/cmd.Execute({0x12ceb84?, 0x19?}, {0x1

Feature improvement: Include overall changes statistics in `summary` subcommand

What could be improved?

Would it be possible to include the change statistics in summary subcommand similar to the one in html-report?

For example, in the generated html report, I could see an overview in the number of changes.
Screenshot 2023-07-06 at 3 10 39 PM

It would be great to see this kind of information in text form in summary subcommand

What's the use case?

Imagine use the tool in the a git pipeline job and as a developer, I want to get a rough idea on the number of changes made, compared to the previous version.

It would also be great to put this information at the bottom (near bottom) of the generated text for convenient view :)

Thank you so much for reading through! πŸ’―

Tests are failing / not up-to-date

How reproduce

❯ go test ./...
go: downloading github.com/stretchr/testify v1.8.4
?   	github.com/pb33f/openapi-changes	[no test files]
# github.com/pb33f/openapi-changes/git [github.com/pb33f/openapi-changes/git.test]
git/read_local_test.go:35:65: not enough arguments in call to ExtractHistoryFromFile
	have (string, string, chan *"github.com/pb33f/openapi-changes/model".ProgressUpdate, chan "github.com/pb33f/openapi-changes/model".ProgressError)
	want (string, string, chan *"github.com/pb33f/openapi-changes/model".ProgressUpdate, chan "github.com/pb33f/openapi-changes/model".ProgressError, int)
git/read_local_test.go:55:64: not enough arguments in call to ExtractHistoryFromFile
	have (string, string, chan *"github.com/pb33f/openapi-changes/model".ProgressUpdate, chan "github.com/pb33f/openapi-changes/model".ProgressError)
	want (string, string, chan *"github.com/pb33f/openapi-changes/model".ProgressUpdate, chan "github.com/pb33f/openapi-changes/model".ProgressError, int)
?   	github.com/pb33f/openapi-changes/cmd	[no test files]
ok  	github.com/pb33f/openapi-changes/builder	0.061s
FAIL	github.com/pb33f/openapi-changes/git [build failed]
?   	github.com/pb33f/openapi-changes/model	[no test files]
?   	github.com/pb33f/openapi-changes/tui	[no test files]
ok  	github.com/pb33f/openapi-changes/html-report	0.005s [no tests to run]
FAIL

The commit that introduced this was 43f7f4b / #100
I suggest to add a workflow that runs go test ./... so that a pipeline asserts that all tests pass before being merged.

The discussion #111 seems related.

Summary command failing with reflect: call of reflect.Value.NumField on zero Value error

Summary command is failing when rendering the comparison between the following two specs:
original.yml

openapi: "3.0.1"
paths:
  /api/v2/sourcing/views/{viewId}:
    get:
      operationId: getViewById
      parameters:
        - name: viewId
          in: path
          description: View ID
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: Successful Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/view"
components:
  schemas:
    view:
      type: object
      description: View model
      properties:
        name:
          type: string
          description: The name of the view
          example: "Example"

modified.yml

openapi: 3.0.1
paths:
  "/api/v2/sourcing/views/{viewId}":
    get:
      operationId: getViewById
      parameters:
        - description: View ID
          in: path
          name: viewId
          required: true
          schema:
            format: int64
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/view"
          description: Successful Request
components:
  schemas:
    view:
      description: View model
      example:
        name: Example
      properties:
        name:
          description: The name of the view
          example: Example
          type: string
      type: object

openapi-changes summary original.yml modified.yml throws the following error:

panic: reflect: call of reflect.Value.NumField on zero Value

goroutine 1 [running]:
reflect.flag.mustBe(...)
        /usr/local/go/src/reflect/value.go:233
reflect.Value.NumField({0x0?, 0x0?, 0x45270f?})
        /usr/local/go/src/reflect/value.go:2062 +0x85
github.com/pb33f/openapi-changes/builder.exploreTreeObject(0xc0003aa380, {0xbe41a0?, 0x0?})
        /opt/openapi-changes/builder/tree.go:42 +0xc5
github.com/pb33f/openapi-changes/builder.BuildTreeMapNode(0xc0003aa2a0, {0xbba320?, 0xc000464068?, 0xba0329?})
        /opt/openapi-changes/builder/tree.go:350 +0xa5
github.com/pb33f/openapi-changes/builder.exploreTreeObject(0xc0003aa2a0, {0xbe41a0?, 0xc000464000?})
        /opt/openapi-changes/builder/tree.go:236 +0x2010
github.com/pb33f/openapi-changes/builder.BuildTreeMapNode(0xc0003aa230, {0xbba320?, 0xc0003a8868?, 0xb81ae4?})
        /opt/openapi-changes/builder/tree.go:350 +0xa5
github.com/pb33f/openapi-changes/builder.exploreTreeObject(0xc0003aa230, {0xbe4da0?, 0xc0003a8860?})
        /opt/openapi-changes/builder/tree.go:236 +0x2010
github.com/pb33f/openapi-changes/builder.DigIntoTreeNode[...](0xc0003aa1c0, {0xbe4da0, 0xc0004183f0?, 0x10e8ca8?}, {0xc0003ad080?, 0xa}, 0x1, 0x0)
        /opt/openapi-changes/builder/tree.go:300 +0x2ea
github.com/pb33f/openapi-changes/builder.exploreTreeObject(0xc0003aa1c0, {0xbe51a0?, 0xc000418380?})
        /opt/openapi-changes/builder/tree.go:141 +0x3185
github.com/pb33f/openapi-changes/builder.BuildTree({0xbe51a0, 0xc000418380})
        /opt/openapi-changes/builder/tree.go:35 +0x9d
github.com/pb33f/openapi-changes/cmd.printSummaryDetails({0xc00039a620, 0x2, 0xc0001eda28?})
        /opt/openapi-changes/cmd/summary.go:404 +0x2bd
github.com/pb33f/openapi-changes/cmd.runLeftRightSummary({0x7ffe0f313f47, 0x1a}, {0x7ffe0f313f62, 0x14}, 0x4?, 0x1007208?, {0x0, 0x0}, 0x0?)
        /opt/openapi-changes/cmd/summary.go:326 +0x8c5
github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1(0xc0001ac100?, {0xc00007eae0, 0x2, 0xd27790?})
        /opt/openapi-changes/cmd/summary.go:228 +0x975
github.com/spf13/cobra.(*Command).execute(0xc000004600, {0xc00007ea80, 0x2, 0x2})
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0x1746560)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/pb33f/openapi-changes/cmd.Execute({0xd284fd?, 0x4012b0?}, {0xd284fd?, 0xd35bce?}, {0xc0000587a0?, 0xc0000061a0?})
        /opt/openapi-changes/cmd/root.go:51 +0xb0
main.main()
        /opt/openapi-changes/openapi-changes.go:29 +0x158

Should `tags` changes be considered breaking?

If you change an OpenAPI spec to rename a tag on an operation, currently the change to the tag will be reported as "breaking" for the contract.

While I can see that if I modify an operation or a model, I'm not sure how changing the tags on an operation could be breaking. I'm curious if tags changes should be marked informational instead.

Deadlock!

Hi!

I installed the openapi-changes package via npm and when I try to run a report or html report between two files I end up with the following deadlock error.

$ openapi-changes html-report merge/devtest.v1.yaml pr/devtest.v1.yaml

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
github.com/pb33f/openapi-changes/model.SendProgressUpdate(...)
        /home/runner/work/openapi-changes/openapi-changes/model/progress.go:26
github.com/pb33f/openapi-changes/git.BuildCommitChangelog({0xc0000c7b28, 0x2, 0xc0000c7b38?}, 0x1?, 0x1?)
        /home/runner/work/openapi-changes/openapi-changes/git/read_local.go:149 +0x334
github.com/pb33f/openapi-changes/cmd.RunLeftRightHTMLReport({0xc0000aa078, 0x15}, {0xc0000aa090, 0x12}, 0x0?, 0x0?, 0x0?)
        /home/runner/work/openapi-changes/openapi-changes/cmd/html_report.go:325 +0x625
github.com/pb33f/openapi-changes/cmd.GetHTMLReportCommand.func1(0xc0001b6900?, {0xc00006e240, 0x2, 0x2?})
        /home/runner/work/openapi-changes/openapi-changes/cmd/html_report.go:175 +0x659
github.com/spf13/cobra.(*Command).execute(0xc0001b6900, {0xc00006e1e0, 0x2, 0x2})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x16ac500)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:968
github.com/pb33f/openapi-changes/cmd.Execute({0x1305ba8?, 0x0?}, {0x130da80?, 0x0?}, {0x1309e30?, 0xc000060000?})
        /home/runner/work/openapi-changes/openapi-changes/cmd/root.go:48 +0xaa
main.main()
        /home/runner/work/openapi-changes/openapi-changes/openapi-changes.go:26 +0x10e

I haven't been able to find any info related to the package that has helped me determine what is causing this. The tool works when I generate a report when compared to a branch's git history, but I'm needing to compare files across branches.

Let me know if you've seen this issue before and what possible resolutions might be! Thanks!

Support left and right comparison between commits

Hi!

There are two use cases that I'd love this tool to cater for:

  1. Before committing changes, a check to see I have not introduced breaking changes to the api spec, either against head or to another branch (i.e. main)
  2. The CI pipeline to detect breaking changes between the head and the base branch on PR

I believe these could potentially be achieved by allowing to optionally specify the git commit/reference:

openapi-changes <revision>:openapi.yaml ./openapi.yaml

Command line option not properly documented

given openapi-changes running the command line without argument gives the following message

Available Commands:
completion Generate the autocompletion script for the specified shell
console Interact with OpenAPI changes in an interactive terminal UI
help Help about any command
html-report Generate the sexiest, most interactive diffing experience you have ever seen.
report Generate a machine readable report for what has changed
summary See a summary of changes

but looks there is no documentation about the completion one (that looks not clear ... 🀨)

Container pb33f/openapi-changes:latest missing GLIBC_2.32, GLIBC_2.34

> docker run --rm pb33f/openapi-changes --help
openapi-changes: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by openapi-changes)
openapi-changes: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by openapi-changes)

This specific latest is sha256:cd5c3d32dd8c11c4b0529afe5ddf2ccc41c15e7ebae2c79819dfcbc6b9e97634. It appears there have been some upgrades to the Dockerfile and build with respect to the Go and dependency versions, I'm guessing that's what brought this on.

build fails due to out-of-date go.sum

broken commit: 2738616

❯ go build
go: downloading github.com/gdamore/tcell/v2 v2.7.4
go: downloading github.com/rivo/tview v0.0.0-20240307173318-e804876934a1
go: downloading github.com/rivo/uniseg v0.4.7
cmd/tree.go:8:2: missing go.sum entry for module providing package github.com/pb33f/libopenapi/datamodel/low/v3 (imported by github.com/pb33f/openapi-changes/cmd); to add:
	go get github.com/pb33f/openapi-changes/cmd
cmd/html_report.go:11:2: missing go.sum entry for module providing package github.com/pb33f/libopenapi/index (imported by github.com/pb33f/openapi-changes/cmd); to add:
	go get github.com/pb33f/openapi-changes/cmd
cmd/flatten_report.go:7:2: missing go.sum entry for module providing package github.com/pb33f/libopenapi/what-changed/model (imported by github.com/pb33f/openapi-changes/cmd); to add:
	go get github.com/pb33f/openapi-changes/cmd
cmd/report.go:16:2: missing go.sum entry for module providing package github.com/pb33f/libopenapi/what-changed/reports (imported by github.com/pb33f/openapi-changes/cmd); to add:
	go get github.com/pb33f/openapi-changes/cmd
model/commit.go:7:2: missing go.sum entry for module providing package github.com/pb33f/libopenapi (imported by github.com/pb33f/openapi-changes/git); to add:
	go get github.com/pb33f/openapi-changes/git
git/read_local.go:12:2: missing go.sum entry for module providing package github.com/pb33f/libopenapi/datamodel (imported by github.com/pb33f/openapi-changes/git); to add:
	go get github.com/pb33f/openapi-changes/git

How to reproduce

  1. clean fresh repository
  2. go build

fixable by running go get github.com/pb33f/openapi-changes/cmd

offline mode support

hey,

i am trying to implement your product in internal private network with no access to outer world.

I talked to @daveshanley on the discord channel and he told me that the product main purpose is to work offline. but it still seems to want to go to the cdn. He also said that the ui model should be replaced to be like in wiretap.

when looking into the bundlejs (/ui/build/static/bundle.js) it contains a reference of the cdn

https://raw.githubusercontent.com/pb33f/openapi-changes/03c1ddd51a4ea6d6dfc8045a294a30d119a30d29/html-report/ui/build/static/bundle.js

Error with private Gitlab URL

It may be staring at me in the face, but I can't see it (the blurred part is just a .foo.com domain I prefer to keep private):

image

Summary command crashing on files with Discriminator objects

Hello! The program crashes when I'm running the summary command on a file containing a Discriminator object. Here's the inputs to reproduce the error:

original.yml:

openapi: "3.0.1"
components:
  schemas:
    Error:
      properties:
        code:
          description: Error code
          type: string
      type: object
      discriminator:
        propertyName: code
        mapping:
          authorization: "#/components/schemas/AuthorizationError"
          error: "#/components/schemas/GenericError"
      oneOf:
      - "$ref": "#/components/schemas/AuthorizationError"
      - "$ref": "#/components/schemas/GenericError"
    GenericError:
      properties:
        code:
          description: Error code
          type: string
      type: object
    AuthorizationError:
      properties:
        code:
          description: Error code
          example: authorization
          type: string
      type: object

modified.yml:

openapi: 3.0.1
components:
  schemas:
    Error:
      properties:
        code:
          description: Error code
          type: string
      type: object
      discriminator:
        propertyName: code
        mapping:
          authentication: "#/components/schemas/AuthenticationError"
          authorization: "#/components/schemas/AuthorizationError"
          error: "#/components/schemas/GenericError"
      oneOf:
        - "$ref": "#/components/schemas/AuthenticationError"
        - "$ref": "#/components/schemas/AuthorizationError"
        - "$ref": "#/components/schemas/GenericError"
    GenericError:
      properties:
        code:
          description: Error code
          type: string
      type: object
    AuthorizationError:
      properties:
        code:
          description: Error code
          example: authorization
          type: string
      type: object
    AuthenticationError:
      properties:
        code:
          description: Error code
          example: authentication
          type: string
      type: object

openapi-changes summary original.yml modified.yml throws the following error:

panic: interface conversion: interface {} is model.DiscriminatorChanges, not model.SchemaChanges

goroutine 1 [running]:
github.com/pb33f/openapi-changes/builder.exploreTreeObject(0xc0002b78f0, {0xbde480?, 0xc000122d20?})
        D:/a/openapi-changes/openapi-changes/builder/tree.go:213 +0x4094
github.com/pb33f/openapi-changes/builder.BuildTreeMapNode(0xc0002b77a0, {0xbb45a0?, 0xc0005a4048?, 0xb7bf44?})
        D:/a/openapi-changes/openapi-changes/builder/tree.go:350 +0xa5
github.com/pb33f/openapi-changes/builder.exploreTreeObject(0xc0002b77a0, {0xbdf080?, 0xc0005a4040?})
        D:/a/openapi-changes/openapi-changes/builder/tree.go:236 +0x2010
github.com/pb33f/openapi-changes/builder.DigIntoTreeNode[...](0xc000189f10, {0xbdf080, 0xc00052c070?, 0x10e13c8?}, {0xc00035ab90?, 0xa}, 0x55, 0x10)
        D:/a/openapi-changes/openapi-changes/builder/tree.go:300 +0x2ea
github.com/pb33f/openapi-changes/builder.exploreTreeObject(0xc000189f10, {0xbdf480?, 0xc00052c000?})
        D:/a/openapi-changes/openapi-changes/builder/tree.go:141 +0x3205
github.com/pb33f/openapi-changes/builder.BuildTree({0xbdf480, 0xc00052c000})
        D:/a/openapi-changes/openapi-changes/builder/tree.go:35 +0x9d
github.com/pb33f/openapi-changes/cmd.printSummaryDetails({0xc00081fbf0, 0x2, 0xc000539a28?})
        D:/a/openapi-changes/openapi-changes/cmd/summary.go:404 +0x2bd
github.com/pb33f/openapi-changes/cmd.runLeftRightSummary({0x7ffdc327331c, 0x12}, {0x7ffdc327332f, 0x16}, 0x4?, 0x1000330?, {0x0, 0x0}, 0x0?)
        D:/a/openapi-changes/openapi-changes/cmd/summary.go:326 +0x8c5
github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1(0xc0002a2100?, {0xc0001d26a0, 0x2, 0xd209f0?})
        D:/a/openapi-changes/openapi-changes/cmd/summary.go:228 +0x975
github.com/spf13/cobra.(*Command).execute(0xc0002b8300, {0xc0001d2640, 0x2, 0x2})
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0x173f2e0)
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/pb33f/openapi-changes/cmd.Execute({0x10c7fb0?, 0x19?}, {0x10d1e60?, 0xd2ed44?}, {0xc0001926a0?, 0xc0000061a0?})
        D:/a/openapi-changes/openapi-changes/cmd/root.go:51 +0xb0
main.main()
        D:/a/openapi-changes/openapi-changes/openapi-changes.go:29 +0x158

Addition of optional query parameters should not be considered as BREAKING CHANGE

Hi,

adding optional query parameters, i.e. required: false is considered as breaking change, but it shouldn't.
Here is a minimal example to reproduce:

original.yaml

openapi: 3.1.0
paths:
  /api/foo:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: string

changed.yaml

paths:
  /api/foo:
    parameters:
      - foo:
          in: query
          name: foo
          schema:
            type: string
          required: false
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: string

output:

openapi-changes version: 0.0.52 | compiled: Fri, 05 Jan 2024 13:54:26 UTC

SPEC extracted 2 commits from history
DONE completed

└─┬Paths
└─┬/api/foo
└──[+] parameters (5:7)❌

Date: 01/15/24 | Commit: New: ./changed.yaml, Original: ./original.yaml
Document Element | Total Changes | Breaking Changes
paths | 1 | 1

❌ 1 Breaking changes out of 1
INFO Additions: 1
INFO Breaking Additions: 1

ERROR breaking changes discovered
Error: breaking changes discovered

[Feature] identify Json schema compatibility

be able to spot that it is semantically compatible
operator:
anyOf:
- type: string
- type: number
- type: 'null'

    vs 
    
operator:
  type:
    - null
    - string
    - number

notice it can be tricky and or out of scope , could be by leveraging a 3rd party ? (asked on Json schema slack ...)

few basic case must be handled such as #104

[bug] paths field display consistency

here i have on top o
bject added: /v1/api/trade-blotter/trade-views to path
and below image
himage

but in same situation i have on top
object added: /v1/api/trade-blotter/trade-views/{viewId} to path
image

issue being on the left side (display the path or not should be consistent)

Add support for Gitlab repositories

Currently, only Github is supported (see #48). This feature request asks for support to be added for Gitlab, too.

Many thanks for creating this tool. It looks very promising.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.