Connectivity
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Change management in ConnectorAPI The document discusses a tool (API versioning) that can be used for faster change management in Connector API. ## Problem Connector API uses deprecation approach to manage changes in the API. The approach considers only backward-compatible changes. Sometimes, doing a change in the API using backward-compatibility is either super complicated or not possible at all. We have one year deprecation policy period, however the policy is mostly ignored, due to the lack of monitoring of the deprecated changes, so we still keep the deprecated code. **The main problem is our inability to evolve API changes as fast as we'd like to.** There are numerous reasons why we want to evolve API: 1. Problematic adaptions of domain changes while keeping the backward compatibility. Some endpoints are overly complicated just to be backward compatible. 2. Slow performance of some API endpoints. Partners selecting and serializing 10k+ entities. We currently don't have a solution to return a larger amount of data. Operation ends with 408 -- request too heavy. 3. Inability to leverage and enforce new design/infrastructure concepts. E.g Switching to read-only replica can't be done in a non-breaking way. ## Solution Each API to evolve needs to have a way to manage changes. We need to improve/introduce an approach that would allow us to discontinue deprecated implementation and have better control over it. Industry-standard is to leverage some kind of API versioning in order to handle breaking changes. *Versioning would allow us to create basically a new endpoint for the same resource--starting from scratch. We could simplify the design of the endpoint, don't care for supporting numerous older implementations, and introduce + enforce some new practices like paginations, shorter timeouts, read-only replicas, etc. Not only that, but at the same time we could easily monitor the usage of the deprecated endpoints.* We managed to live 7 years without versioning in the ConnectorAPI. We should be really cautious when introducing a new version--bulk multiple deprecated versions together, keeping in mind forward compatibility... Using API versioning wouldn't solve the whole problem. It's just a tool that can allow for a faster-paced development and address the limitation in the backward-compatible approach. In the meantime we created a [survey](https://mews.typeform.com/to/JCpBXN9h) to collect thoughts on what is the preferred way of API versioning for partners. From what we've heard so far, endpoint versioning using URI seems like the most likable approach. So far we've seen one internal partner (Kiosk team) preferring API versioning whilst the survey shows that the majority of our external partners advocate for endpoint versioning. Process of discontinunation is not part of RFC and could be done in future, aligned with the partners preferences. List to our current deprecations [deprecation documentation](https://github.com/MewsSystems/gitbook-connector-api/tree/develop/deprecations) ### What to version We can consider multiple versionable units in our case. Endpoint, entity, or the whole API. | **Scope** | **Explanation** | **Pros** | **Cons** | |-----------|---------------------------------------------------------------------------|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | Endpoint | Individual endpoint. `v2/reservations/getAll` | + More granular + Client can update only the desired endpoint | - Each endpoint evolving on its own -- variety in latest version | | Entity | All operations on entity. `v2/reservations/{getAll\|add\|update\|...}` | + Unified version per entity | - Client must update all operation for the entity - In between from endpoint and API versioning. | | API | Entire API. `v2/{reservations\|companies\|rates\|...}/{getAll\|add\|...}` | + Unified latest version across the whole API | - Client must incorporate all previously changed endpoints - Single change in an endpoint requires bumping the whole API version | There is not that big of a difference for us from the implementation point of view. When it comes to our internal consumers, currently there are some preferring endpoint and some API versioning. API versioning unifies the version across the whole API and ensures that all changes are consumed when upgrading to the latest version. Endpoint versioning does it more granularly. There is no need to incorporate changes implemented from other endpoints. ### How to version Once we settle up on what to version, next important question is to discuss how to implement the API versioning itself. | **Versioning approach** | **Explanation** | **Pros** | **Cons** | |-------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------| | URI | Increase the version in the URL. `**v2**/reservations/getAll` | + Simple and unambiguous, easy to test + We already have the version in the API + Simplest implementation + Easier caching for clients | - Depends on the versioning scope. Might be confusing to have multiple versions for different endpoints/resources. | | Custom header | Keep the path, but include the custom header with the version. It could be integer, date, whatever. | + URI is not cluttered by the version | - Custom header is required - Caching becomes more complicated | | Request body | Keep the path, and header. Version is passed as a field in the request body. | + Everything is handled in a single method | - More complicated documentation (swagger) - More complicated endpoint logic - Deserialization of the whole request is required | | Query parameters | `v1/reservations/getAll?v=1` | + Unified root version | - 2 versions at the same URL might creates confusion | As the version is already part of our URI end it's not tieing us more to the REST, URI versioning seems like our best bet. ### Detailed design of endpoint versioning The idea is pretty simple really. All of our API paths typically follow: `/api/{controller}/{version}/{entity}/{operation}` e.g. `/api/connector/v1/reservations/getAll`. By having a version embedded in the URL, this shouldn't be that big of a hassle from an API's uniformity and usability point of view. Once there is a need to create a new version of a particular endpoint, we simply introduce a new version of that endpoint whilst immediately deprecating the current one. Ensuring we have at most *2* versions of the same endpoint available is key not to lose control over numerous different behaviors in different versions. It can be achieved by code analyzers. At the same time, it would keep us cautious with introducing a new version each time there is a change in the API. We should rather pragmatically introduce a new version only when there is a need for that -- performance, too much backward compatibility, breaking change. Leveraging API versioning and having problematic endpoints rewritten in an optimized and more scalable way would allow us to simply ask the affected partner to adopt the newer version. *All of the problems mentioned in the problem section are addressable by adopting the versioning. Once a new version of an endpoint is available, we need to make a strict deadline for deprecation and notify the partners about it. All new integrations should use the latest version. We should monitor the traffic to older endpoints and could build some New Relic dashboards with the ratio between old/new versions. This should give us insight into the usage of the deprecated endpoint as we currently can't tell whether the deprecated fields are still used by some partner* It seems like URI versioning is the right path for us. It is simple, unambiguous, intuitive, easily understandable + testable, when the logic changes, the URL changes. Even more when we already have the version embedded in the URL. There is probably no need to introduce the minor versions (v1.1) for connector API (could be beneficial in our internal APIs, though). When the survey will show us that API versioning is indeed something partners are used to and we could go for it, not much is going to change. We would simply bump the version of the whole API, introduce the newly versioned endpoint and route the rest of the endpoints to the old implementation. New versions of the endpoint must be included in the swagger next to the old version, whilst the old version is marked as deprecated. We could benefit from implementing preview endpoint versions. Such versions of endpoints are not included in the swagger/documentation and can be used by a pilot partner to test, and tune the functionality. We would be able to do breaking changes presuming those will be well communicated. This should prevent us from unnecessary versioning of an endpoint, as the new version should be more mature. The simplest possible implementation is to move the version from the controller level to each individual endpoint. Creating a new endpoint and bumping up the API version. ``` [Route("api/general")] public partial class GeneralApiController : JsonApiController<Dto.Parameters> ... ``` All endpoints then need to be versioned explicitly. ``` [HttpPost] [Route("v1/enterprises/getAll")] [RequestBody(typeof(Dto.MultipleEnterpriseParameters))] [SuccessResponse(typeof(Dto.MultipleEnterpriseResult))] public Task<ActionResult> GetAllEnterprisesAsync() ... ``` Afterward, adding a new version of an endpoint should be as simple as adding a new endpoint with bumped-up version. ``` [HttpPost] [Route("v2/enterprises/getAll")] [RequestBody(typeof(Dto.MultipleEnterpriseParameters))] [SuccessResponse(typeof(Dto.MultipleEnterpriseResult))] public Task<ActionResult> GetAllEnterprisesV2Async() ... ``` We could introduce something like VersionedRouteAttribute, that prepends the version `v{version}/` into the route. POC can be found [here](https://github.com/MewsSystems/gitbook-connector-api/). Run locally, then just open http://localhost:61785/Swagger/general/swagger.yaml to check the generated swagger.yaml. See: ![Swagger-ui](../../images/swagger-ui-versioned.PNG) Alternatively, we could also use the package `Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer`. That would allow versioning via query parameters, headers, etc. It could benefit from parametrized version (no custom attribute needed). But for our purposes, the approach specified above should be enough. ### Version lifecycle *The creation of a new version should be considered as a last resort. All changes that could be done in a backward-compatible way, should be done that way.* [Endpoint versioning process](../../images/api-versioning.PNG) *Simple idea of endpoint versioning is displayed above.* *There is v1 version. Add v2 version, while marking the v1 as deprecated (e.g. in 6 months). Once the deprecation period is reached, notify partners still using soon to be discontinued version (by client token). Give some more time (2 months) and discontinue v1. When requested it can return 301 -- permanently moved to with the link to documentation/new version. Alternatively, we could do discontinuation once v3 is going to be added.* ### Drawbacks - Supporting multiple versions of basically the same thing -- possibly violating DRY ### Alternatives -Keep managing the API changes using deprecation policy, but follow strict deprecation policy: Issue with this approach is that although it might be more convenient for the clients, endpoints would be cluttered by numerous execution paths to support different "versions". Thus the implementation would be more error prone. At some point (6-12 months) we would need to discontinue the deprecated endpoints/fields so the not-migrated partners will be broken. There is no simple way to granularly monitor usage of the deprecated endpoints, so we can't pinpoint clients still using the deprecated fields and warn/notify just those. -One option of change management is to create a new resource each time we need to "version" an endpoint. `reservations/getAll` -> `serviceOrders/getAll` while this applies to reservations endpoint, it wouldn't be scalable, and we could be cluttered by numerous deprecated/obsolete resources. -Another way is to do something like `v1/reservations/getAllV2` to get the granularity of the endpoint versioning while keeping the API version unified. But this, similarly to query parameters, just seems overly confusing and not user-friendly. ### Next steps - Analyze the results of the survey sent to the partners and agree on the scope of the versioning. The current proposal assumes endpoint versioning. If we will find out that API versioning is more feasible, the RFC is going to be updated. - Setup the discontinuation approach. Agree on how to communicate changes, and deprecation timeline (again from the survey). This should not have a big impact on the implementation. ## Unresolved questions We are creating questionnaire for partners about which versioning scope suits them most (endpoint/API). Technology (URI/header/...). Deprecation duration. How they'd like to be notified about the changes.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully