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

Unsure how to enable Swagger UI / JSON when running from Docker #116

Open
johnbeech opened this issue Mar 7, 2023 · 4 comments
Open

Unsure how to enable Swagger UI / JSON when running from Docker #116

johnbeech opened this issue Mar 7, 2023 · 4 comments

Comments

@johnbeech
Copy link

johnbeech commented Mar 7, 2023

After reading:

And running GoNorth via docker instructions...

By default, I get no response on the endpoints.

And if I change this code:

            if(env.IsDevelopment())
            {
                app.UseSwagger();

                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "GoNorth Api");
                });
            }

to

            if(true)
            {
                app.UseSwagger();

                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "GoNorth Api");
                });
            }

(and rebuild docker with docker-compose up --build, I get a HTML page with name, showing this error:

Error
An error occured while processing the request.
Request ID: 00-e6aff5e7c39413fbae94d37ea5ff7a78-2b16cca9e5ce881c-00

And this error on the command line:

gonorth-web-1    | fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
gonorth-web-1    |       An unhandled exception has occurred while executing the request.
gonorth-web-1    |       System.IO.FileNotFoundException: Could not find file '/app/GoNorth.XML'.     
gonorth-web-1    |       File name: '/app/GoNorth.XML'

Would like to build a client to export data from the tool to use with my prototype game system. I thought the Swagger API would be a good place to start.

@steffendx
Copy link
Owner

The problem seems like the docker-compose up is not generating the documentation xml file (or the path to it is different).
It should work if you run GoNorth from the command line using dotnet run.

But since you are mainly interested in the swagger file, I have simply attached the file to this response:
gonorth_swagger.txt
You will have to rename this file back to .json since json files are not allowed to be attached to task, apparently.
You should then be able to simple import this file to the Swagger UI

Does that work?

@johnbeech
Copy link
Author

This has been some spaghetti... so... I've managed to load gonorth_swagger.json into Swagger UI Dist, which involved a bunch of string and tape...

image

But when I call one of the commands, e.g. /api/KirjaApi/SearchPages

image

image

For the record, I'm proxying http://localhost:7200/api/ to http://localhost:5000/ - where GoNorth is running in Docker.

I think this would be much cleaner if I could get it running and hosted correctly via Docker. Basically I feel like all my data is stuck inside the GoNorth instance at the moment and is quite difficult to get at.

@johnbeech
Copy link
Author

Stored my reference code a gist:

@steffendx
Copy link
Owner

Thanks for providing a gist! I'll check it out soon. It might be a login issue, but then you should get a 401 and not a 500. I'll report back as soon as I know more.

In the meantime: If accessing the webservices are too complicated (I did not really worked on them being easily accessible for a third party application) and you mainly want to extract data, you might simply access the MongoDB?
Its a fairly easy data structure and you will get almost the same results from access the MongoDB then access the Rest API.

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

2 participants