Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot read property 'charAt' of undefined #1616

Closed
Chiliukas opened this issue Sep 18, 2018 · 13 comments
Closed

Error: Cannot read property 'charAt' of undefined #1616

Chiliukas opened this issue Sep 18, 2018 · 13 comments

Comments

@Chiliukas
Copy link

I can not load my JSON file on ReDoc. I can open JSON file in a browser.
The same JSON working with UseSwaggerUi3WithApiExplorer.

I used UseSwaggerReDocWithApiExplorer in another project and works fine. But now ReDoc was implemented in project with 400 endpoints. It is hard to debug and find witch attribute missing for endpoint.

The problem is with generated JSON file. And redoc.min.js can not handled it. Somehow i must figured out witch endpoints must be changed.

I am using:
.NET CORE 1.0.2.
NSwag.ApiNetCore 11.19.2.0

        app.UseSwaggerReDocWithApiExplorer(s =>
        {
            s.SwaggerRoute = "/redoc/v1/swagger.json";
            s.SwaggerUiRoute = "/redoc";
        });

image

image

@RicoSuter
Copy link
Owner

can you post the swagger.json to reproduce this?

@RicoSuter
Copy link
Owner

@RomanGotsiy any idea? You probably need the swagger.json, right?

@Chiliukas
Copy link
Author

I can not give JSON file. Company rules.
And in JSON is 20 000 lines.

Maybe you can give me some tips how to debug.

@RicoSuter
Copy link
Owner

Is it working with SwaggerUi3?

@Chiliukas
Copy link
Author

Chiliukas commented Sep 19, 2018

Working if i am using this code:

            app.UseSwaggerUi3WithApiExplorer(s =>
            {
                s.SwaggerRoute = "/swagger_new_ui3/v1/swagger.json";
                s.SwaggerUiRoute = "/nswagger";
            });

Not loading and can not open JSON file in browser if i am using this code:

        app.UseSwaggerUi3(s =>
        {
            s.SwaggerRoute = "/swagger_ui3/v1/swagger.json";
            s.SwaggerUiRoute = "/swaggerui3";
        }); 

image

But it is okay if i am using UseSwaggerUi3 and loadning JSON file from "/swagger_new_ui3/v1/swagger.json" (JSON file generated by UseSwaggerUi3WithApiExplorer).

In addision. With UseSwaggerReDocWithApiExplorer I can open JSON file generated from another project (another project generated JSON file by UseSwaggerReDocWithApiExplorer).

I can give some parts of JSON, but i can not give it all (begining file, enum, some methods).

@RomanHotsiy
Copy link

From the stacktrace, I can only guess it has something to do with type: file fields.

If you could locate the exact field that breaks and post it here it would be super useful.

@Chiliukas
Copy link
Author

@RomanGotsiy I sent an e-mail to you (gotsijroman@gmail.com) with a JSON file. I hope this will help you understand more clearly what the problem is.

@RicoSuter
Copy link
Owner

If there is a problem with the NSwag output, please report here

@RomanHotsiy
Copy link

@Chiliukas I checked out you spec and hunted down the issue to the following snippet:

"files": {
  "type": "array",
  "items": {
    "type": "file"
  }
}

If you remove it, ReDoc doesn't crash (you can use it as a temporary workaround). It is clearly a ReDoc 1.x bug and has nothing to do with NSwag ouput. I opened a corresponding issue in ReDoc repo.
@Chiliukas you can close this issue (cc @RSuter).

I checked the same spec with redoc@2.0.0-alpha.38 and the issue can't be reproduced with it.
While I will fix 1.x bug, @RSuter is there a chance NSwag can support ReDoc@2.x?

@RicoSuter
Copy link
Owner

RicoSuter commented Sep 20, 2018

@RomanGotsiy currently we are using 1.x in the middleware. Can I just switch to the new 2.x version without any problems for users? Or are there some serious breaking changes or some important features which are missing in the 2.x version? Thanks for investigating this problem...

@RomanHotsiy
Copy link

@RSuter yes, it should just work.
Make sure to load it from jsdelivr or unpkg instead of out GitHub pages based CDN as I stopped deploying to it since 2.x. Check out README.

@RicoSuter
Copy link
Owner

@RomanGotsiy thanks for your answer, can you quickly check the linked PR? Is this fine?

@Chiliukas
Copy link
Author

@RomanGotsiy @RSuter Thanks for your answers and investigating this problem. You have helped me a lot. Now everything is working well. It looks like nSwag has very strong support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants