redoc icon indicating copy to clipboard operation
redoc copied to clipboard

2.0.0-alpha.x issues

Open RomanHotsiy opened this issue 9 years ago • 97 comments

Leave any issues you found during testing 2.0.0-alpha.x releases here (just not to make so much noise in https://github.com/Rebilly/ReDoc/issues/327)

RomanHotsiy avatar Nov 23 '17 10:11 RomanHotsiy

Awesome job :)

My swagger definition does not work yet: https://cloud.squidex.io/api/swagger/v1/swagger.json

SebastianStehle avatar Nov 23 '17 10:11 SebastianStehle

@SebastianStehle your spec is failing during converting it to OpenAPI 3 using swagger2openapi because you have combination of collectionFormat and type: file while collectionFormat is supposed to be used only with type: array:

image

RomanHotsiy avatar Nov 23 '17 10:11 RomanHotsiy

@RomanGotsiy are you passing options.patch and options.warnOnly in the conversion? I'd recommend it! Full options documentation.

MikeRalphson avatar Nov 23 '17 11:11 MikeRalphson

Ok, I fixed it and there are no more warnings in the swagger editor:

https://gist.githubusercontent.com/SebastianStehle/33f9dd6c02ace0b60dd434d5354b3bbf/raw/e8701476e499fc25726ee755780adf614597ce91/Squidex.json

Now I get another error.

SebastianStehle avatar Nov 23 '17 11:11 SebastianStehle

@MikeRalphson thanks for the suggestion! I will enable those options in the next alpha!

@SebastianStehle yes, I can see this issue too. It is also indirectly caused by conversion process. I am now discussing the best ways to fix it with @MikeRalphson.

It will be definitelly resolved in the next alpha. Right now I've workaround it by replacing all type: file in responses by

type: string
format: binary

You can check workarounded spec here

RomanHotsiy avatar Nov 23 '17 11:11 RomanHotsiy

But with the updated spec I get the other error. But I am pretty sure that you will solve it :)

SebastianStehle avatar Nov 23 '17 12:11 SebastianStehle

But with the updated spec I get the other error. But I am pretty sure that you will solve it :)

You need to patch out the collectionFormat issue again in @RomanGotsiy 's copy to work around both issues.

MikeRalphson avatar Nov 23 '17 12:11 MikeRalphson

Oh, sorry. Thats awesome. Even some of my problems with the stable version are fixed :)

SebastianStehle avatar Nov 23 '17 12:11 SebastianStehle

I've just published v2.0.0-alpha.2 with those issues resolved.

RomanHotsiy avatar Nov 23 '17 12:11 RomanHotsiy

Works perfectly for my original definition :)

SebastianStehle avatar Nov 23 '17 12:11 SebastianStehle

@RomanGotsiy I talked with you about this issue a few weeks ago on Twitter and I put another example at https://github.com/mikunn/openapi-test-allof/blob/master/allof.yaml.

So the issue is that properties in nested allOfs get lost. Running that specs shows only the meta property in the response and href and location are lost.

We reuse lots of stuffs in our specs, so that's why we have allOfs all over the place. We can probably use a separate merger before feeding the spec to ReDoc, but would be nice to get a support directly from ReDoc :)

Respect the effort as always! The docs seem crazy responsive 👍

mikunn avatar Nov 23 '17 13:11 mikunn

Hey @mikunn,

thanks for reminding me! Thanks to your precise examples, it was very easy for me to reproduce the issues and to fix them both in v2.0.0-alpha.3!

Thanks, @mikunn!

RomanHotsiy avatar Nov 23 '17 14:11 RomanHotsiy

Great work. Thanks!

Does the new react ReDoc works with multiple specs? I used the same multiple example html as with 1.x.x. version. The first Redoc.init works fine, but the onClick Redoc.init(url); doesn't do anything. Any idea how I can fix it or any workaround?

      // initially render first API
      Redoc.init(apis[0].url);
      function onClick() {
        var url = this.getAttribute('data-link');
        Redoc.init(url);
      }

suds-kumar avatar Nov 23 '17 19:11 suds-kumar

Fantastic! Thanks for the fast fix, @RomanGotsiy, works perfectly!

I still have another issue where ReDoc doesn't start at all displaying error "Cannot read property '$ref' of undefined". I created a new repo again at https://github.com/mikunn/openapi-test-refs. swagger.yaml is the main file. The issue is very hard to reproduce from scratch and I tried to simplify a real failing spec as much as possible.

The issue appears when there are complex $refs and, again, allOf has probably something to do with it. If you remove pretty much any $ref from any of the schemas.yaml file, it starts working. Also, if you comment out either path in the swagger.yaml file, it starts working.

Maybe there are too many references to the same file (probably root schemas.yaml) from many places and ReDoc loses track at some point?

This issue is in alpha-1 as well, so recent changes didn't break it.

mikunn avatar Nov 24 '17 06:11 mikunn

@mikunn I'm not sure allOf has anything to do with this issue. I think it's an issue of visibility of the rest of an included document when you're using a fragment identifier. It may be undefined behaviour as to whether internal $refs in the included document should be resolved and can 'see' properties outside of this fragment.

In my resolver (which is not the one used by ReDoc) it creates this issue:

#/paths/~1base/get/responses/200/content/application~1json/schema/allOf/1/properties/meta/$ref
Cannot resolve reference: #/components/schemas/Meta

This is because I'm trying to preserve internal $refs, not dereference every one. However, that $ref only has meaning inside that document... It's not possible to attach the referenced components.schemas content to the root OpenAPI object (it might use definitions instead of components.schemas for example), so rewriting the $refs is problematic. Resolving those internal $refs might be the only sensible approach.

The JSON-Reference spec seems woolly on this point, and helpfully, does not feature any examples. Do you have a particular reading of the spec?

MikeRalphson avatar Nov 24 '17 08:11 MikeRalphson

With everything resolved (it seems when you start resolving, it is dangerous to stop), I see this issue:

#/paths/~1me/get/responses/200/content/application~1json/allOf/1
Schema object cannot have additionalProperty: customer

from:

  /me:
    get:
      tags:
        - Me
      summary: Summary of Me
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - allOf:
                      - type: object
                        properties:
                          href:
                            type: string
                      - customer:
                          type: object
                          properties:
                            id:
                              type: integer
                            href:
                              type: string

This patch 'resolves' (ho-ho) it:

diff --git a/me/schemas.yaml b/me/schemas.yaml
index 9a9a9ad..7efb479 100644
--- a/me/schemas.yaml
+++ b/me/schemas.yaml
@@ -7,5 +7,5 @@ components:
     MeOut:
       allOf:
       - $ref: '../schemas.yaml#/components/schemas/SelfHref'
-      - $ref: '#/components/schemas/Me'
+      - $ref: '#/components/schemas/Me/customer'

MikeRalphson avatar Nov 24 '17 08:11 MikeRalphson

@mikunn If you want to resolve/validate your OpenAPI 3.0 definitions as above, you can use swagger2openapi:

node testRunner -v -r swagger.yaml

or

node swagger2openapi -v -r swagger.yaml -o resolved.yaml

The online version at https://openapi-converter.herokuapp.com has also been updated to the latest version.

MikeRalphson avatar Nov 24 '17 08:11 MikeRalphson

@mikunn your case causes dereferencing issue in the ref parser I use. I've been able to simplify it a bit more but anyway it's really weird. I'll try to investigate it when I have spare time but can't promise it will be fixed quickly.

RomanHotsiy avatar Nov 24 '17 09:11 RomanHotsiy

@RomanGotsiy you could always have a ReDoc option which uses swagger2openapi's resolver instead, just set options.resolve to true. You'd need ^2.11.5 as above.

MikeRalphson avatar Nov 24 '17 09:11 MikeRalphson

Thanks guys for the responses!

I've used json-refs to dereference which works well with that spec, but it still leaves some refs behind. json-schema-ref-parser or swagger2openapi should do the trick. Thanks for the example, @MikeRalphson :+1:.

No rush with the fix, I can do the extra dereferencing step until this is fixed :) The other issue that are already fixed were way more important!

I will try our other specs later and see how things work!

mikunn avatar Nov 24 '17 11:11 mikunn