DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Techniques You Should Know as a Kafka Streams Developer
  • How to Merge DOCX Files and Replace Text Strings in Java
  • Source-Driven Development in Salesforce: Managing Metadata and API Versions
  • How to Introduce a New API Quickly Using Micronaut

Trending

  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • Prioritizing Cloud Security Risks: A Developer's Guide to Tackling Security Debt
  • Introduction to Retrieval Augmented Generation (RAG)
  • The Perfection Trap: Rethinking Parkinson's Law for Modern Engineering Teams
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Use Compare and Merge for SwaggerHub

How to Use Compare and Merge for SwaggerHub

Read on to find out how to keep API documentation shipping moving forward smoothly by using Compare and Merge for SwaggerHub.

By 
Keshav Vasudevan user avatar
Keshav Vasudevan
·
Dec. 07, 16 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
7.9K Views

Join the DZone community and get the full member experience.

Join For Free

API description formats like Swagger act as a contract between the API provider and end consumer, clearly detailing all of the resources and operations of the API in a format that’s both human and machine readable. Using Swagger to document your RESTful APIs enables easier development, better discovery, and an overall better integration experience for the end consumer.

As a provider using Swagger to define an API, you have the responsibility to keep that contract up-to-date, which often requires managing multiple versions of your Swagger definition.

If you are someone who’s following a “code first” approach to Swagger (which means having to use annotations to generate the Swagger spec from the code of your API), you may find that there are some tweaks needed to create a well-designed definition for your API.

Whatever approach your team follows to define your API with Swagger, there’s a good chance there are a number of different people, with different skill sets and responsibilities, involved in the process.

Involving the Right People in API Documentation

Developers and API designers aren’t the only one’s involved in the design and documentation phases of the API lifecycle. If your team is serious about documenting your API, you likely have a technical writer whose responsibility is to improve your API’s usability by providing concrete documentation that works with your API’s various resources.

That person may not be actively involved in the initial development of the API, and as a result, he or she will often have to invest a lot of time understanding how to write a description for an API endpoint that is accurate and provides the right amount of context for the end user.

This documentation workflow involves a lot of collaboration between the developer, technical writer, and anyone else involved in publishing the API. And also requires the right amount of traceability to ensure that nothing breaks when making an update to the definition.

The Right Tools for Your Documentation Workflow

Here at SwaggerHub, we’ve worked hard to provide tools to make it easier for all of the members of your team to work together throughout the lifecycle of your API. With features like comments and team management, you can get feedback, raise questions, and resolve issues in real-time.

Now, we are excited to announce our newest improvement to SwaggerHub, which will make it even easier to compare Swagger definitions, review and verify changes, and accept updates to your Swagger spec.

Introducing Compare and Merge for SwaggerHub

Whether you’re updating a Swagger definition that’s already in use or adding Swagger to an existing API, it’s helpful to compare the changes you’re making before you update the API.

You can compare and merge your API specification stored in SwaggerHub with another API spec that is stored in a YAML or JSON file in your file system, be it from your local machine or to another definition stored in SwaggerHub.

Unlike a traditional diff and merge solution, the SwaggerHub Compare and Merge feature is built specifically for reviewing and implementing changes to the Swagger definition. It provides the right amount of feedback and will help validate that your API is accessible based on the changes you’re making to the definition.

Here’s a closer look at how the Compare and Merge tool works:

Compare With a Swagger Definition in SwaggerHub

  1. In SwaggerHub, open your API for editing. Switch to the needed version.
  2. Click the gear icon in the top right corner of the editor and select Compare and Merge API from the menu:
    compare-and-merge-command
  3. In the subsequent dialog, select Compare to Spec in SwaggerHub.
    compare-with-spec-in-swaggerhub
  4. In the next dialog, specify the username, API, and the API version for comparison.
    compare-with-spec-in-swaggerhub-2

To compare the API with another version of the same API, enter your username, the API name and choose another version.

  1. Click Next. SwaggerHub will validate that the API is accessible.

If the validation is successful, click Next again. This will invoke a window where you can see the difference between the APIs.

Compare With a Swagger File

  1. In SwaggerHub, open your API for editing. Switch to the needed version.
  2. Click the gear icon in the top right corner of the editor and select Compare and Merge API from the menu.
  3. In the subsequent dialog, select Compare to an external Spec.
    compare-with-spec-in-file
  4. In the next dialog, enter the URL of the desired JSON or YAML API, or specify the API file on your hard drive:
    compare-with-spec-in-file-2
  5. Click Fetch. SwaggerHub will load the specified API and check if it is valid.

If the loaded API is valid, click Compare. This will open a window where you can see the difference between the APIs (see below). If the loaded API in invalid, you will see a message describing the problem.

Below is a sample view of the Difference Window.

difference-window

Your API is on the right; the “other” API is on the left. SwaggerHub automatically detects and highlights the changed lines.

The Diff Type setting at the bottom of the window specifies the differences that SwaggerHub highlights:

Value Description
Design and Metadata SwaggerHub highlights the differences in property values and new and deleted nodes.
Design only SwaggerHub highlights only the changes in the specification structure, for example, new or deleted nodes. The differences in property values are not highlighted.

Merging Differences

  1. Click the highlighted difference line (or block) on the right or left part of the window. SwaggerHub will copy the block from the left side of the window to the right side (that is, to your API) and will remove highlighting. It will also increase the counter in the Undo button.
  2. Click Undo to revert the most recent approval, if needed. To revert several approvals, click Undo several times.
  3. After you merge all the needed differences, click Save Changes to save the changes. This will replace your API specification with the changed one.

If you wanted only to view the differences (that is, to compare two API specifications), click Cancel.

API Merge (version control)

Published at DZone with permission of Keshav Vasudevan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Techniques You Should Know as a Kafka Streams Developer
  • How to Merge DOCX Files and Replace Text Strings in Java
  • Source-Driven Development in Salesforce: Managing Metadata and API Versions
  • How to Introduce a New API Quickly Using Micronaut

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!