steffendx / GoNorth

GoNorth is a story and content planning tool for RPGs and other open world games.
MIT License
571 stars 30 forks source link

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

Open johnbeech opened 1 year ago

johnbeech commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Stored my reference code a gist:

steffendx commented 1 year ago

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.