beckn / protocol-specifications

Core protocol specification for peer-to-peer consumer-provider interaction
Other
375 stars 101 forks source link

Feat: automated Open API syntax validation on submitting PR to master #443

Open homosapien14 opened 2 months ago

homosapien14 commented 2 months ago

Description (fixes #366 )

Problem: Sometimes when pull requests are merged, syntactical errors in the OpenAPI document get committed to the master branch, which can lead to integration issues and broken functionality.

Feature Request: Implement an automated script that validates OpenAPI specifications when a pull request is created. The script should specifically validate transaction.yaml, meta.yaml, and registry.yaml against the OpenAPI 3.0 specification.

Goals:

Solution

How I Solved It:

Workflow Configuration:

Validation Script:

Expected Outcome

Acceptance Criteria

How to Test

  1. Create a Pull Request:

    • Make changes to the OpenAPI files (transaction.yaml, meta.yaml, registry.yaml) in a new branch and open a pull request targeting the master branch.
  2. Check Workflow Execution:

    • Ensure the GitHub Actions workflow runs automatically.
    • Verify that the validation steps execute correctly.
  3. Test with Errors:

    • Introduce syntactical errors in the OpenAPI files and observe if the workflow fails and reports the errors.
  4. Test without Errors:

    • Ensure that a PR with valid OpenAPI files passes the checks successfully without any errors.
homosapien14 commented 2 months ago

@ravi-prakash-v Hii , could you please review it once.

homosapien14 commented 2 months ago

@rajaneeshk90 can you please look at this?

VedantKhairnar commented 2 months ago

Hello @harshcrop Will you pls review the contribution? Thanks.

homosapien14 commented 1 month ago

hey @harshcrop , can you even give me a feedback?

rajaneeshk90 commented 1 month ago

Hi @homosapien14,

Thank you for submitting the PR! I appreciate your effort.

I have a few suggestions that could help improve the submission:

Thanks again for your contribution!

Best regards, Rajaneesh

VedantKhairnar commented 1 month ago

Hello @homosapien14 Any update on this? Also, Augtoberfest ends on 15th Sept, so it would be great if we finish this before that. Thanks.

homosapien14 commented 1 month ago

Hi @rajaneeshk90, Thank you for your response. I am sorry for the delay (I was busy with the office project deadline).

I have made the required changes as you suggested in this 82fa17b commit.

How to Test the Changes

  1. Create a New Branch:

    • First, create a new branch from swapnil/openapispecs.
    • Update the push branches in the validate-openapi.yml file to your new branch name (xyz).
    • Push the changes to the remote repository.
  2. Test the Workflow:

    • Create a new branch from master and make invalid changes (e.g., introduce syntax errors or remove required lines) in the meta.yaml, registry.yaml, or transaction.yaml files.
  3. Push and Create a Draft PR:

    • Push the invalid changes to the remote repository.
    • Create a draft pull request with the target branch set to xyz.
  4. Check the CI Workflow:

    • The GitHub Actions workflow will run automatically.
    • It should throw an error in the CI step if there are any issues with the OpenAPI files, such as syntax problems or missing fields.

    Here are the sample errors while I was testing the implementation:

image

testing1