mrin9 / OpenAPI-Viewer

OpenApi viewer Implemented using Vue
https://mrin9.github.io/OpenAPI-Viewer/
104 stars 21 forks source link

[BUG] $ref file error #7

Closed maosong closed 4 years ago

maosong commented 4 years ago

e.g.

MrinDoc Server: http://localhost:8080

json-url: http://www.domain.com/openapi.json

{
  "openapi": "3.0.0",
  ...
  "paths": {
    "/staffs": {
      "$ref": "./paths/staffs.json"
    }
  }
  ...
}

$ref-url: http://www.domain.com/paths/staffs.json

{
  "get": {
    ...
  }
}

Now load json-url, MrinDoc can't load the correct $ref-url, but load http://localhost:8080/paths/staffs.json

maosong commented 4 years ago

I modified src/lib/parserUtils.js and tested it successfully.

...more...

export default function ProcessSpec(specUrl) {
    let p;
    let options = { patch: true, warnOnly: true }
    if (typeof specUrl === "string") {
        p = $RefParser.dereference(specUrl, options);
    }
    else {
        p = converter.convertObj(specUrl, options)
            .then(function (api3Spec) {
                console.info("%c Convertion to OpenAPI 3.0 - Success !!! ", "color:cornflowerblue");
                return $RefParser.dereference(api3Spec.openapi);
            });
    }
    return p
        .then(function (deReffedSpec) {
            console.info("%c OpenAPI 3.0 Dereferencing - Success !!! ", "color:cornflowerblue");

...more...

Is it feasible?

mrin9 commented 4 years ago

fixes to this project will be little delayed as I am focusing on an alternate to this RapiDoc. If you can move towards an web-component based solution then I strongly suggest you to use RapiDoc which is being actively developed and has more features and themes than MrinDoc

maosong commented 4 years ago

🙏Thank you!