Schema and swagger


#1

I have some issues trying to get swagger-ui to directly import the openapi schema, it seems like there is something about api star doing a 302 redirect for the schema. The schema itself is validated and looks fine, the typing system is really nice.

I have never worked with swagger/openapi before, are the common way of working with the schemas to export them before displaying them into a swagger gui or do you usually connect the guis directly?

If anyone got experience with this any help in this area would be greatly appriciated.


#2

You can unpack the dist directory of the Swagger-UI zip at the APIStar statics directory.


#3

I just pointed swagger directly to /schema and it displayed correctly.


#4

Seem to be working doing that approach yes, thank you


#5

So here is what I did:

  1. I got the swagger-ui-dist package from npm

    cd /tmp
    npm install swagger-ui-dist
    
  2. Moved it into my project:

    cd $MY_PORJECT
    mkdir static/
    mv /tmp/node_module/swagger-ui-dist static/docs
    
  3. Edit the url=... (line 44) in $MY_PROJECT/static/docs/index.html and make it read url="../../scheam/"

  4. Setup static files as described in https://docs.apistar.com/api-guide/static-files/

And now when I am going into http://127.0.0.1:8080/static/docs/index.html I have a read-only interaction with my schema. But I am unable to send requests and get responses as I was able to do with ApiStar 0.3.9.

Is this all there is right now, or did I missed some important step along the way?

Update: issue#515: OpenAPI security fields, should part of the solution I was looking for.


#6

After the 0.4 rejig, interactive documentation was removed, but I do believe it will be reintroduced at some point.


#7

Is it possible you’re missing the trailing slash? Use http://<host>:<port>/schema/ for the URL.


#8

There is a typo in step 3. It should be schema, you have scheam
But even after fixing that, it is not working for me. I am still redirected to default petstore.

I directly tried 127.0.0.1:5000/schema which asks me to “save the file”
I saved it as /tmp/apistar.yaml - The file looks correct i.e. has my API in OAS 3.0 format.

But how to make it interact with swagger-ui ?

Edit:
This may be problem with swagger-ui’s latest version.
See open question on stackover flow