SwaggerHub allows you to store the specification in popular source control management tools.

The following steps will help you integrate your GitHub repo with SwaggerHub in 6 simple steps.

  • After defining the specification, click on the ‘Integrations’ tab, as shown below.
  • Click on ‘Add New Integrations’ and select the option for ‘GitHub Sync’ from the dropdown menu.
  • Type the name of the GitHub-SwaggerHub integration to identify the integration. This will be used later in dealing with the integration using Registry API, which will be discussed in our next blog.

Type the output file name, i.e., the file name of the specification that will be pushed to the repository, and click on ‘Connect to GitHub’.

  • Enter credentials to log in to GitHub.
  • You may receive an email to verify the sign-in attempt. Click on the review link in the email and check the SwaggerHub page again. You will see the text field with an increased number of configured values in the Integration configuration prompt box, as shown below.

*poc-petstore is a new repository that has been configured for this API specification (can be selected via the dropdown).

*The token value will be generated automatically after providing the credentials.

*Repository owner is the default owner of the configured repository.

  • Set values for other parameters.
    • Set Branch as apidefinition (if not present, a new branch will be created while executing the integration).
    • Set Sync Type to Basic Sync – if there are no files present in the branch, and Advanced Sync – if files and folders are present.
    • Define the type of code to sync your GitHub repository with and the output folder for the generated code or specification. Here, we have set the type of code as YAML (unresolved) and the output folder as apispec.
  • Click ‘CREATE AND EXECUTE’ and you will be able to view the integration name in the integration list.

You will be able to see the OAS3.0 specification in the folder apispec, as shown below.

Congratulations! You have successfully connected your GitHub repo with SwaggerHub.

Agnel Roysten
Software Engineer

Ready to get started?

Contact us Close