<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mehdi Raza on Medium]]></title>
        <description><![CDATA[Stories by Mehdi Raza on Medium]]></description>
        <link>https://medium.com/@thehappybug?source=rss-33aeb6b9000e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*adbc78a5V-PkfIEU_DJmYQ.jpeg</url>
            <title>Stories by Mehdi Raza on Medium</title>
            <link>https://medium.com/@thehappybug?source=rss-33aeb6b9000e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:48:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thehappybug/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing Core Libraries in SDKs]]></title>
            <link>https://medium.com/apimatic/introducing-core-libraries-in-sdks-fd61b030b2e9?source=rss-33aeb6b9000e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd61b030b2e9</guid>
            <category><![CDATA[apimatic]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[code-generator]]></category>
            <category><![CDATA[openapi3]]></category>
            <dc:creator><![CDATA[Mehdi Raza]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 08:54:20 GMT</pubDate>
            <atom:updated>2023-07-03T16:52:23.042Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L9idV7aoU4eoRXS87DQ0jA.jpeg" /></figure><blockquote>We’re <a href="https://www.apimatic.io/">APIMatic.io</a>. We generate strongly typed SDKs along with a complete API reference from OpenAPI definitions. If you’re looking to create an SDK for your REST API, check out how to <a href="https://www.apimatic.io/blog/2022/08/how-to-create-sdks-for-your-api-in-less-than-a-minute/">generate one in under a minute</a>. This post covers a major enhancement to the design of our generated SDKs, aligned with our mission to provide zero-maintenance SDKs to API providers.</blockquote><p>In this release, we have majorly revamped SDKs to improve the code quality, reduce code size, and provide better test coverage than ever. At the center of these changes are the new <strong>Core Libraries </strong>which now help power the SDKs and provide many new quality of life improvements for SDK users. Despite these improvements, we have taken care to make sure that the SDKs have no breaking changes with this release.</p><h3>Why did we redesign our SDKs?</h3><p>Every SDK that we generated in the past contained some common utility code. This utility code which we often call the <strong>SDK Internals</strong> provided functionality like the ability to create HTTP requests, handle responses, facilitate authentication, convert API responses back to class instances, and validate user and server data.</p><figure><img alt="What goes inside an SDK?" src="https://cdn-images-1.medium.com/max/1024/1*oJH7oF_Qpzjv04pxUyOazg.png" /></figure><p>So even though the most interesting part of the SDK are the endpoint methods and the models (a.k.a. data classes) which are part of the <strong>SDK’s Interface</strong>, these work by building on top of the SDK Internals which do all the heavy lifting needed to make the SDKs work<strong>.</strong></p><p>Not only do SDK Internals themselves contain significant logic for making API calls happen, they also pull in dependencies to help power the SDK functionality. For example, they can pull in an HTTP client library to help make the HTTP calls for the API, or perhaps a JSON serializer library to help convert Data Objects to and from JSON.</p><p>This makes SDK Internals a crucial part of the SDKs on which the rest of the SDK’s work depends. To ensure that the SDK keeps working, we need to provide updates for the SDK Internals, the kind of updates that fix bugs, patch vulnerabilities and provide other improvements to the SDK.</p><p>However, that’s where we run into a limitation with our previous design.</p><figure><img alt="Can we improve our SDK design?" src="https://cdn-images-1.medium.com/max/1024/1*vjuL0zy5YXijXf5Q3rf0sQ.png" /></figure><p>The SDK Internals were part of the SDKs. This meant that fixing them required generating a new SDK as well. Even when an API provider did that, this would only get them an updated SDK for the latest version of their API. Meanwhile all the old SDK versions that are still used by the API users contain SDK Internals that might need to be updated for vulnerabilities or bug fixes.</p><p>Generating new SDKs everytime a small bug fix or dependency update needs to happen multiplied for every SDK version is definitely impractical for API providers! So we set about to solve this problem with a redesign.</p><h3>What are Core Libraries?</h3><p>That is where Core libraries enter the game.</p><figure><img alt="What are Core libraries?" src="https://cdn-images-1.medium.com/max/1024/1*-rlaiVdifg5wmFViztlVkQ.png" /></figure><p>The solution to our code duplication problem was simple. We redesigned the SDKs so that all SDK Internals that were previously part of the SDK itself are now externalized into a library, the <strong>Core library</strong>, which is installed into the SDK just like any dependency (more on that later).</p><p>This means most of the code inside the SDKs now consists of code that is specific to the API. This usually consists of the endpoint methods and data models that are generated by the APIMatic Code Generator using the OpenAPI definition. The SDK Internals was code that stayed mostly unchanged from SDK to SDK is no longer part of the SDK code base.</p><p>This dramatically reduces the amount of code that is present in the generated SDKs. This helps us provide even better care of the generated SDKs by taking charge of when and how Core libraries are updated. Let’s see how that happens.</p><h3>Core Libraries keep your SDKs fresh</h3><p>With SDK Internals code out of the SDK and into a Core Library, you must be wondering who is responsible for maintaining the Core Library and updating it. APIMatic’s team, of course!</p><figure><img alt="Who updates the SDKs and the Core libraries?" src="https://cdn-images-1.medium.com/max/1024/1*H2tBHdKgn3mHtgl7ZoyGzA.png" /></figure><p>All SDKs use the latest Core Libraries by installing them via the <strong>package repository</strong>. A package repository is a public database where library authors publish their libraries for anyone to use. For example, npm for Node.js or Pypi for Python are the de facto package repositories for their respective languages. APIMatic maintains the Core Libraries and publishes new versions of them to the package repositories whenever there is an update. These updates then make it into the SDKs by virtue of the SDKs depending on the latest version of the Core Library.</p><p>This solves a big problem in the maintainability of the SDKs: how to update both new and old SDKs.</p><figure><img alt="How Core libraries help SDKs stay updated after release?" src="https://cdn-images-1.medium.com/max/1024/1*t4KnkB3Qc-haK-2HjpdOew.png" /></figure><p>Whenever APIMatic fixes a vulnerable dependency or makes some performance improvement, these automatically make it into all the SDKs without the need for anyone to generate a new SDK from our Code Generator. This means that we are able to push updates and fixes faster than ever before without any additional effort from the API providers.</p><h3>Core libraries help deliver updates to the SDK</h3><p>Let’s dive a little deeper into the kind of updates Core libraries receive:</p><ol><li><strong>New features</strong>: These include new functionality in the SDK such as API call retries or HTTP caching. Often functionality like this also requires a new SDK to be generated.</li><li><strong>Improvements</strong>: Smaller changes like improved error messages were made available to the users without the need to update their SDKs. Improvements to HTTP calls, JSON serialization and validation happen frequently.</li><li><strong>Language updates</strong>: Most languages see new version releases every year. To help make sure that your SDK continues to work on a new language runtime, we provide compatibility updates to our Core libraries as well as our SDKs when needed.</li><li><strong>Bug fixes</strong>: These include patches to issues reported by our customers.</li><li><strong>Dependency updates</strong>: Libraries used by the Core library to make HTTP requests or serialize JSON see frequent updates. These updates can help introduce new features or performance improvements, for example updates to the HTTP client to introduce HTTP/3 support.</li><li><strong>Vulnerability fixes</strong>: Third-party dependencies require patches from time to time. We track such vulnerabilities using a vulnerability scanner and alert tool and provide updates when available.</li></ol><h3>Core Libraries improve SDK maintainability</h3><p>Core libraries help push updates and improvements to old and new SDK versions automatically, improving the maintainability of the SDKs. However, while working on Core Libraries, we used this opportunity to improve the code that goes inside the SDK as well.</p><p>As we designed the Core libraries, we thought about what a clean interface between the SDK and the Core library would look like. For us, a clean interface meant that the SDK contained only code that was necessary for the SDK to function and specific to the API for which the SDK was generated for. All other code should be delegated to the Core libraries which should provide the implementation details for the SDK.</p><p>With this goal in mind, we were able to majorly revamp our implementation code for API calls. Checkout a sample of what an endpoint method (method that makes an API call) looks like in a generated Java SDK before and after our redesign:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQvrDyvVNpbDo-BmxamgdA.png" /><figcaption>Comparing an API call implementation in the Java SDK before and after Core Libraries</figcaption></figure><p>That’s almost half the code! This coupled with redesigning the SDKs so that most of it consists of declarative code that is implemented using Core Libraries has had a positive effect on the testability of the SDK as well.</p><figure><img alt="How Core libraries improve SDK test coverage?" src="https://cdn-images-1.medium.com/max/1024/1*8cKIJWW7GBMrwvnm3wvw1g.png" /></figure><p>These test suites are part of the Core Libraries’ codebases and can be viewed on GitHub. For example, checkout the test coverage numbers in PHP’s Core library:</p><figure><img alt="Test coverage numbers in PHP’s Core library" src="https://cdn-images-1.medium.com/max/1024/1*q72LrX0TeAwiIgVoFctAow.png" /></figure><h3>Core Libraries provide an Open-Source core for the SDKs</h3><p>Having the source for the Core libraries published on GitHub allows us to engage with a wider community of developers to gather bug reports and to get pull requests for fixes and new features. It also provides visibility to the public into the test suites that we run to maintain our projects, something that was not previously available outside of APIMatic. That means the SDK users can now refer back to the code that powers their SDK and submit improvements for it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TB7Zr_1xevS-Xh9NHF7BDA.png" /><figcaption>Screenshot from GitHub showing the PHP Core library repository</figcaption></figure><p>We follow all the best practices expected of a Open Source library such as:</p><ul><li>Continuous testing via our test suites and GitHub Actions</li><li>Checking code quality through linting and static analysis checks</li><li>Tracking maintainability through Code Climate</li><li>Vulnerability checks and alerts via Dependabot</li><li>Open collaboration via a permissive MIT license</li></ul><p>We are also excited about the possibilities of having alternative implementations for some of the functionalities provided by the Core library, thanks to modularization of the SDK through Core libraries and the fact that this code is now open source.</p><figure><img alt="How Core libraries allow fflexibility in dependencies?" src="https://cdn-images-1.medium.com/max/1024/1*o12pfUE_JbQZcOqlmo6l1w.png" /></figure><p>This creates the opportunities for API providers and SDK users to customize SDKs for their specific needs to meet their business requirements. Think HTTP clients that integrate neatly with their web framework of choice or serialization libraries that integrate directly with the Dependency Injection framework they use.</p><h3>Summary</h3><p>This release represents one of the biggest refactoring of the SDKs generated by APIMatic. We have redesigned the SDKs for all of the currently supported languages in our Code Generator. This means when you generate the SDKs now, they will be using the new design and will depend on the Core Libraries to provide their functionality.</p><figure><img alt="SDKs using Core libraries" src="https://cdn-images-1.medium.com/max/1024/1*zynBdm-WpSFgBQDKmCO-Wg.png" /></figure><p>Core libraries have not only improved the SDK quality story but will help us iterate even faster in the future. If you haven’t tried out APIMatic’s Code Generator, <a href="https://www.apimatic.io/blog/2022/08/how-to-create-sdks-for-your-api-in-less-than-a-minute/">do try it out</a> and let us know what you think.</p><p><em>Originally published at </em><a href="https://www.apimatic.io/blog/2023/06/core-libraries-in-sdks/"><em>https://www.apimatic.io</em></a><em> on June 27, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd61b030b2e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apimatic/introducing-core-libraries-in-sdks-fd61b030b2e9">Introducing Core Libraries in SDKs</a> was originally published in <a href="https://medium.com/apimatic">APIMATIC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We've Rewritten our Developer Experience Portal and you’re gonna love it ]]></title>
            <link>https://medium.com/apimatic/weve-rewritten-our-developer-experience-portal-and-youre-gonna-love-it-e14cefe02e75?source=rss-33aeb6b9000e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e14cefe02e75</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-documentation]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[developer-experience]]></category>
            <dc:creator><![CDATA[Mehdi Raza]]></dc:creator>
            <pubDate>Wed, 01 Aug 2018 12:58:44 GMT</pubDate>
            <atom:updated>2018-08-01T17:20:32.398Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEt7Q1uNLSW3nMaX8t9LIQ.png" /></figure><p>Greetings! Our Developer Experience Portal is already into its next version! We did not pack our bags after <a href="https://www.producthunt.com/posts/developer-experience-portal">launching the first version</a> last month, and are proud to present Developer Experience Portal Version 1.1. This time even more optimised, more beautiful, and more Developer friendly. The new version is packed with a number of improvements and some new features.</p><blockquote>Read what makes APIMatic&#39;s <a href="https://blog.apimatic.io/introducing-portals-that-speak-your-devs-language-bac82a8c573f">Developer Experience portal different</a> from other available solutions.</blockquote><h3>🔨 Built from Ground Up to be Awesome</h3><p>The new portal is written from scratch, based on our new internal <strong>Documentation Format </strong>that powers much of the interactive parts of docs such as the console and reactive code snippets.</p><p>This will enable us to implement more <strong>complex features </strong>in the future without being limited by markup languages such as Markdown.</p><h3>✍️ ️<strong>Overhaul of Typography</strong></h3><p>The design of typography (textual elements such as headings, paragraph, lists, etc) has been overhauled. The new portal brings <strong>massive improvements to the look of the content</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fy_P4QCUmMfw90eXCYndQQ.png" /></figure><h3>👨‍💻 Redesigned API Reference</h3><p>Endpoint reference has been redesigned and now looks much <strong>cleaner</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*USLklSloeoR3JIleDnQtow.png" /></figure><p>Also, types are now <strong>linked </strong>to their definitions for easier navigation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akJ1bDIT9LGupWxCxkEfsQ.png" /><figcaption>Now linking to properly to models and enumerations in parameters table.</figcaption></figure><h3>🎚️ <strong>Switching between Languages</strong></h3><p><strong>Switching </strong>between language maintains the endpoint or model or whatever section is open. Config in console is also persisted between languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*POtnjKzJYhCAvQrF6W3dyg.gif" /></figure><p>We’ve added <strong>icons </strong>in the language drop-down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*T42G2_USrBQ9R0X4uc0gnA.png" /></figure><h3>🍭 <strong>Improved Embedded Mode</strong></h3><p>Menu looks better in the <strong>embedded </strong>(two-column) mode. Large menus will scroll now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yDV9JwbhyDktH3lab9d2dA.png" /></figure><h3>🔍 Quick Jump</h3><p>We’ve added <strong>fuzzy search </strong>that helps quickly jumping to endpoints and models. It can also be triggered from the <strong>keyboard </strong>using Ctrl+K .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*vGz-syA7CtCfHug8mJ8AOA.gif" /><figcaption>Using the keyboard to quickly navigate documentation.</figcaption></figure><h3>🍃 Gentler Error Messages</h3><p>We’ve improved the <strong>messaging </strong>in case an API call fails in the API console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*FXNrUiM2lguTvIT10JtZUQ.png" /></figure><h3>🏃 Faster, Lighter</h3><p>The new portal is written to be fast and light. Despite adding new features, we’ve actually shed weight <strong>resulting in about 33% reduction in size</strong>.</p><p>The new portal optimizes for a perception of fast loading speed by delaying loading of non-critical components until they are needed. This results in <strong>a 71% reduction in size on first load</strong>. Technical implementation details can be read <a href="https://medium.com/@thehappybug/using-react-context-in-a-typescript-app-c4ef7504c858">here</a>.</p><h3>⭐️ How do I get this?</h3><ul><li>Read how to <a href="https://docs.apimatic.io/changelog/developer-experience-portal-major-release/"><strong>upgrade your existing portal</strong></a><strong> </strong>to the newest version.</li><li>Or create one from scratch using our <a href="https://apimatic.io/developer-experience-portal"><strong>portal generator</strong></a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e14cefe02e75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apimatic/weve-rewritten-our-developer-experience-portal-and-youre-gonna-love-it-e14cefe02e75">We&#39;ve Rewritten our Developer Experience Portal and you’re gonna love it 🎉</a> was originally published in <a href="https://medium.com/apimatic">APIMATIC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using React Context in a TypeScript App]]></title>
            <link>https://medium.com/@thehappybug/using-react-context-in-a-typescript-app-c4ef7504c858?source=rss-33aeb6b9000e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4ef7504c858</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[context]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Mehdi Raza]]></dc:creator>
            <pubDate>Thu, 12 Jul 2018 10:26:42 GMT</pubDate>
            <atom:updated>2018-07-12T10:44:57.181Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bz7bOXNGvq1YIH3C3lKtPg.jpeg" /></figure><p>Recently I had the opportunity to use the new React 16 library which comes with features such as the Context API and Error Boundaries. This article covers my experience using the Context API in a TypeScript app.</p><p><strong>🚩 From </strong><a href="https://reactjs.org/docs/context.html"><strong>React’s official documentation</strong></a><strong>:</strong></p><blockquote>Context provides a way to pass data through the component tree without having to pass props down manually at every level.</blockquote><p>This saves the programmer from having to pass these properties down through components<em> which might not even need to use these properties</em>. In my app, I needed to globally share data that resembled application settings but was loaded from an API.</p><p>To use the new Context API, <strong>first ensure that you have the latest version of React and its type files</strong>. The new version contains several bug fixes and improvements for the Context API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd70b81aa847e00bfde0f2b91ef7e31c/href">https://medium.com/media/dd70b81aa847e00bfde0f2b91ef7e31c/href</a></iframe><h3>Creating the Context</h3><p>Creating a Context is easy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d895b8854c9294375bb52ffde14a4dde/href">https://medium.com/media/d895b8854c9294375bb52ffde14a4dde/href</a></iframe><p>The createContext<em> </em>create a Context object with a default value. The Context object requires one type parameters which TypeScript will automatically infer from the defaultValue<em> </em>provided.</p><p>A more useful case would be where the defaultValue<em> </em>is a non-trivial type such as an object. Let’s define an interface for our context’s data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6852405ea863e07d6de33f59d44dcb65/href">https://medium.com/media/6852405ea863e07d6de33f59d44dcb65/href</a></iframe><p>Unfortunately, TypeScript’s compiler will complain here as providing a defaultValue is compulsory. I find this requirement of Context API absurd because in many cases, a meaningful default value can not be provided.</p><p>We can workaround this limitation by changing the context’s type parameters a bit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cba637e981b8810d90883ce78e11d137/href">https://medium.com/media/cba637e981b8810d90883ce78e11d137/href</a></iframe><p>Notice how we had to pass in null as a default value.</p><p>We should now add the correct exports for your provider and consumer (which we explore next) as well as the data interface.</p><blockquote><strong>Pro-tip:</strong> Rename your provider and consumer to have unique names before exporting them. This makes it easier to auto-import them in VS Code.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36eb0e807fb59e82294e7ae472b7c299/href">https://medium.com/media/36eb0e807fb59e82294e7ae472b7c299/href</a></iframe><h3>Providing the Context</h3><p>Somewhere in your App, you will create a context provider which will pass down the value you provide to all the descendant consumers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1790b174d84bbe7c0c054bc20b3be0e/href">https://medium.com/media/a1790b174d84bbe7c0c054bc20b3be0e/href</a></iframe><p>In this example, I’ve passed a constant as a value to the AppContextProvider<em> </em>but this could easily have been a value loaded from an API or stored in the component state.</p><h3>Consuming the Context</h3><p>Now we create a context consumer that will receive the context value as long as it is a descendant of a context provider.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0425ad682fe770762e577d084c4aa600/href">https://medium.com/media/0425ad682fe770762e577d084c4aa600/href</a></iframe><p>The AppContextConsumer<em> </em>subscribes to context changes. In this example, we’re creating a <em>div </em>that contains the Name, Author and Url values which are retrieved from the context and updated whenever the context value changes.</p><p>AppContextConsumer<em> </em>requires a <a href="https://reactjs.org/docs/render-props.html#using-props-other-than-render">function as a child</a>. This function receives the context value and returns a JSX element.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/855c5048738b69957d9ff75c4da58841/href">https://medium.com/media/855c5048738b69957d9ff75c4da58841/href</a></iframe><p>In our case, the appContext<em> </em>has the type AppContextInterface | null<em> </em>so we must check for null<em> </em>or else the TypeScript compiler will complain if we try to use appContext<em>. </em>This is why I used {appContext =&gt; appContext &amp;&amp; …}<em> </em>here.</p><blockquote><strong>Pro-tip:</strong> Using an HOC (which I cover next) instead of the Context consumer component results in more readable code.</blockquote><h3>Higher-Order Component for Consuming Context</h3><p>If a lot of components depend on context, it can quickly become tedious to wrap each one in &lt;AppContextConsumer&gt;<em>.</em> Instead, we can use a Higher-Order Component (HOC):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe31c48f78d56c160707f5660ee3af2f/href">https://medium.com/media/fe31c48f78d56c160707f5660ee3af2f/href</a></iframe><p>That makes using context so easy! 🎉 Just wrapping any component that accepts an appContext<em> </em>property with withAppContext()<em> </em>makes it a subscriber to our context.</p><h4>Implementing the HOC in TypeScript</h4><p>Writing the HOC in TypeScript can become complicated so its worth looking at an example from React’s documentation first: this is written in JavaScript but adapted for our use-case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2fb97a9e1c5c228627a5cb857b83a3c/href">https://medium.com/media/b2fb97a9e1c5c228627a5cb857b83a3c/href</a></iframe><p>Since the official React documentation does not give TypeScript examples, it took me sometime to write a properly type-checked HOC. Here it is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ef398574e2f87c2af18c3bdaaf09d03/href">https://medium.com/media/7ef398574e2f87c2af18c3bdaaf09d03/href</a></iframe><blockquote><strong>Pro-tip: </strong><a href="https://gist.github.com/thehappybug/88342c122cfb1df9f14c9a10fb4926e4">Bookmark this snippet for Context HOC</a>! You’re gonna need it many times during React-TypeScript development. You can thank me later. <em>😏</em></blockquote><p>Note that if the TypeScript compiler complains on <em>Exclude </em>keyword then you’re using a version of TypeScript older than 2.8 which does not support conditional types; fix this by updating your TypeScript compiler.</p><h3>Complete Example in Action 🏃</h3><p>Checkout the complete example I’ve put together on Code Sandbox that shows all the pieces (Context, Consumer and Provider) in action.</p><p>You can also edit this example! 😃</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F72mwrln600%3Fautoresize%3D1%26fontsize%3D12%26hidenavigation%3D1&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F72mwrln600%3Fautoresize%3D1%26fontsize%3D12%26hidenavigation%3D1&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F72mwrln600%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/a99cc1e1776bb96d42625225edaa3243/href">https://medium.com/media/a99cc1e1776bb96d42625225edaa3243/href</a></iframe><p>Here’s another version which implements the same functionality but <strong>uses Higher-Order Component to consume Context</strong>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Folm74m134y%3Fautoresize%3D1%26fontsize%3D12%26hidenavigation%3D1&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Folm74m134y%3Fautoresize%3D1%26fontsize%3D12%26hidenavigation%3D1&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Folm74m134y%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/48748e96f163851534ecbdfeddd73592/href">https://medium.com/media/48748e96f163851534ecbdfeddd73592/href</a></iframe><h3>Next Steps 👣</h3><ul><li>Read: the <a href="https://reactjs.org/docs/context.html">official documentation</a> for the React Context API.</li><li>Follow: the incredible <a href="https://medium.com/u/33aeb6b9000e">Mehdi Raza</a> for more adventures in React land. 👍</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4ef7504c858" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revamped HTTP docs on API Portal ]]></title>
            <link>https://medium.com/apimatic/revamped-http-docs-on-api-portal-4cac51d63a2f?source=rss-33aeb6b9000e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cac51d63a2f</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[curl]]></category>
            <category><![CDATA[api-console]]></category>
            <category><![CDATA[dynamic-code-samples]]></category>
            <category><![CDATA[http-docs]]></category>
            <dc:creator><![CDATA[Mehdi Raza]]></dc:creator>
            <pubDate>Thu, 22 Mar 2018 10:12:21 GMT</pubDate>
            <atom:updated>2018-03-22T10:12:21.552Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQYPnI16EpWWMQt-5eC0lQ.png" /></figure><p>The fight for improving the <a href="https://blog.apimatic.io/introducing-portals-that-speak-your-devs-language-bac82a8c573f">Developer Experience in API portals</a> is not over yet!</p><p><strong>In fact, we have just released a major revamp of HTTP documentation to all our customers. 🎉</strong></p><p>Let’s see the new features in details.</p><h3>👨‍💻 New Curl Examples</h3><p>Our HTTP docs now show API console with <em>Curl </em>commands for each endpoint.</p><h4>What is Curl, you say?</h4><p>It is a nifty tool for making HTTP calls from the terminal, popular with developers. <a href="https://curl.haxx.se/">Curl </a>can be installed on Linux, MacOS and Windows.</p><p>Here’s what a simple Curl command looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/010843dce7c6f63356c4e97a2783c82b/href">https://medium.com/media/010843dce7c6f63356c4e97a2783c82b/href</a></iframe><h4>What’s in our Curl Examples?</h4><p>Our API portal uses examples from the API description file to create Curl commands which are then shown in the endpoint documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpAoe9714CxWsQiEVP3ceg.png" /><figcaption>Curl example for sending an API call via Telstra’s API</figcaption></figure><p>Checkout how the Curl command contains all the right headers; it even caters for API authentication and the body format of the request.</p><p>In fact, the Curl examples fully integrate with the <strong>API Console letting the user change the endpoint parameters while those changes are reflected in the example live.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mm9lrSK4xZh__Ysy_TJ6pg.gif" /></figure><p>The user can just copy and paste the Curl command in their favorite terminal to run it.</p><h3>🔒 Improved Authentication docs</h3><p>Our Authentication section now shows detailed docs for common authentication types such as HTTP basic, OAuth 2 and custom API keys.</p><p><strong>These docs include Curl examples so that the users can try them out in the terminal.</strong> Check out this example for an API that uses OAuth 2 Client Credentials grant:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*2BiQXttPHNRGiD8cKuvahg.png" /><figcaption>Example of auto-generated Auth docs</figcaption></figure><p>All of this is auto-generated from the API description file!</p><h3>⭐️ Can your Portal do this?</h3><p>Our API portals have:</p><ul><li><a href="https://docs.apimatic.io/developer-experience-portal/api-console/">API console with Reactive Code Samples</a></li><li>Language-specific documentation (for 10 languages)</li><li>Lots of other goodies :)</li></ul><p><a href="https://apimatic.io/developer-experience-portal"><strong>Give our portal generator</strong></a><strong> a try!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cac51d63a2f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apimatic/revamped-http-docs-on-api-portal-4cac51d63a2f">Revamped HTTP docs on API Portal 🆕🎉</a> was originally published in <a href="https://medium.com/apimatic">APIMATIC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>