Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malformed YAML structure for endpoints #183

Closed
peruzzof opened this issue Feb 16, 2023 · 3 comments · Fixed by #184
Closed

malformed YAML structure for endpoints #183

peruzzof opened this issue Feb 16, 2023 · 3 comments · Fixed by #184

Comments

@peruzzof
Copy link

peruzzof commented Feb 16, 2023

Describe the bug
When using the diff with YAML format the Endpoints/Modified structure has a malformed YAML structure because the key is not a string.

To Reproduce
Steps to reproduce the behavior:

  1. Run oasdiff.exe -format=text -base petstore.yaml -revision petstore_2.yaml -format yaml
  2. We will receive an malformed YAML because key under endpoints/modified 2 strings as identifier:
paths:
    modified:
        /pets:
            operations:
                modified:
                    GET:
                        parameters:
                            added:
                                query:
                                    - page_size
endpoints:
    modified:
        ?   method: GET
            path: /pets
        :   parameters:
                added:
                    query:
                        - page_size

Expected behavior
The structure under endpoints/modified can be converted to an array with one "id" structure and the "changes", in this case it will be presented as:

endpoints:
- modified:
  - id:
    - method: GET
      path: "/pets"
    changes:
    - parameters:
      - added:
        - query:
          - page_size

A second alternative is to exclude this structure from the YAML, using a flag or by default.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] 1.3.1

Additional context
petstore.yaml at https://gist.githubusercontent.com/peruzzof/affe59e40f5b257751462775775b7b7c/raw/b0d2299c3a3eba76bcb96bf9258bef68aaf50f74/petstore.yaml

petstore_2.yaml at https://gist.githubusercontent.com/peruzzof/affe59e40f5b257751462775775b7b7c/raw/b0d2299c3a3eba76bcb96bf9258bef68aaf50f74/petstore_2.yaml

@peruzzof peruzzof changed the title malformed YAML structure malformed YAML structure for endpoints Feb 16, 2023
@reuvenharrison
Copy link
Collaborator

Hi @peruzzof,
Please see: #94 and let me know if it solves the problem.
Reuven

@peruzzof
Copy link
Author

Hi @reuvenharrison, thanks again for your effort. I understood the point but, in my use case, I have two different options right now:

  1. Forget the "yq" tool and create a custom script to be able to handle the yaml format
  2. Create an external script to get the YAML, remove the entire "endpoints" section and keep using yq (or jq)
  3. Wait for yq to properly handle this feature (Implement the "complex mapping key" from YAML spec mikefarah/yq#1559)

As none looks very interesting I took a look and seems feasible to add the -exclude-endpoints flag, similar to exclude-examples that already exist. I was able to create the core of it (using the existing code as an example), if I submit a PR could you review it?
Please keep in mind that I have almost no experience with Go, so it will require more effort from your side then a regular suggestion.

@reuvenharrison
Copy link
Collaborator

Got it.
So let's support exclude endpoints and then we can also output json.

@reuvenharrison reuvenharrison linked a pull request Feb 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants