이것은 일반적인 질문입니다. 내 Swagger API는 IE11, Chrome, FireFox 외에도 IE10을 사용할 때 잘 작동하며 오류가 발생하면 failed to parse JSON/YAML
이고 swagger.inspec().state
은 다시 "rejected"
이됩니다. 나는 또한 내가 API_URI 전체 URL을하지만, 단지 경로로 정의하지 않은 이유는 프록시 서버를 사용하고IE10 Swagger 오류가 JSON/YAML을 구문 분석하지 못했습니다.
import { API_URI } from '../config/app_config'; // '/accountservice/swagger.json'
import Swagger from 'swagger-client'; // "swagger-client": "^2.1.17"
export const buildAccountServiceClient =() => {
const swagger = new Swagger({
url: (!window.location.origin ? IE_API_URI : API_URI),
usePromise: true,
});
// Reconfigure swagger client to override service path if we're using a reverse proxy:
// /accountservice/swagger.json -> /accountservice
// Originally tried setting basePath to null, undefined, and '', but that didn't work
let basePath;
if (API_URI.startsWith('/')) {
basePath = API_URI.substring(0, API_URI.lastIndexOf('/'));
swagger.then((client) => {
client.setBasePath(basePath);
if (typeof(window) !== 'undefined') {
// use current protocol, so either http or https
client.setSchemes([window.location.protocol.slice(0, -1)]);
}
});
}
return swagger;
};
: 내 클라이언트를 인스턴스화하고 방법은 다음과
이다.
IE10이 지원 되더라도 IE10을 제외한 다른 모든 브라우저에서이 기능이 작동하는 이유는 무엇입니까?
어떤 Swagger UI 버전입니까? 최신 3.0.x [IE10을 지원하지 않습니다] (https://github.com/swagger-api/swagger-ui#browser-support). – Helen
아니요. "swagger-client"를 사용하고 있습니다. "^ 2.1.17"' https://github.com/swagger-api/swagger-js/issues/1018에서 조금 더 자세한 내용을 추가했습니다. –