Magento 2 API – Swagger Can’t read from file

When you use swagger as your testing tool for the API, it is possible that you get the error Can’t read from file. This can easily be solved by installing the Experius ApiExtend module: 

The reason that this error occurs is because you have changed the storecode default to a custom store code. You can solve the problem easily in your own template by adding the following file to your custom theme, but of course  I recommend to install the Experius ApiExtend module.

app / design / frontend / Vendor/ your_theme_here / Magento_Swagger / templates / swagger-ui / index.phtml

 * swagger-ui - Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS
 * assets that dynamically generate beautiful documentation from a Swagger-compliant API
 * @version v2.1.1
 * @link
 * @license Apache-2.0
 * The original name of this file, as part of the swagger-ui package, was dist/index.html.
 * Modified by Magento, Modifications Copyright © 2016 Magento.

/** @var \Magento\Framework\View\Element\Template $block */

$schemaUrl = rtrim($block->getBaseUrl(), '/') . '/rest/<strong>place_your_storcode_here</strong>/schema?services=all';

<div id='header'>
    <div class="swagger-ui-wrap">
        <a id="logo" href="">swagger</a>
        <form id='api_selector'>
            <input id="input_baseUrl" type="hidden" value="<?php /* @escapeNotVerified */ echo $schemaUrl ?>"/>
            <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
            <div class='input'><a id="explore" href="#" data-sw-translate>apply</a></div>

<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>