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

Update Swagger to OpenAPI 3.0 for Enabling JWT #10

Closed
wants to merge 1 commit into from

Conversation

steffes
Copy link

@steffes steffes commented Feb 17, 2020

It is not possible to generate clients from swagger 2.0 when common.yaml contains type: JWT which is an OpenAPI 3.0 feature. See: swagger-api/swagger-ui#3860 (comment)

@luke-
Copy link
Contributor

luke- commented Feb 19, 2020

Thank you for the PR.

For some reason I cannot build the redoc HTML doc with your change..

$ ./build-all.sh
--------- activity.yaml ---------------------
Prerendering docs

🎉 bundled successfully in: ../html/activity.html (52 KiB) [⏱ 0.363s]
--------- auth.yaml ---------------------
Prerendering docs

🎉 bundled successfully in: ../html/auth.html (38 KiB) [⏱ 0.189s]
--------- calendar.yaml ---------------------
Prerendering docs

🎉 bundled successfully in: ../html/calendar.html (86 KiB) [⏱ 0.374s]
--------- cfiles.yaml ---------------------
Prerendering docs

🎉 bundled successfully in: ../html/cfiles.html (92 KiB) [⏱ 0.433s]
--------- comment.yaml ---------------------
Prerendering docs

🎉 bundled successfully in: ../html/comment.html (42 KiB) [⏱ 0.179s]
--------- common.yaml ---------------------
Prerendering docs
TypeError: Cannot read property 'description' of undefined
    at new ApiInfoModel (/usr/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:8275:45)
    at new SpecStore (/usr/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:8626:21)
    at new AppStore (/usr/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10511:21)
    at Module.<anonymous> (/usr/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:10495:43)
    at step (/usr/lib/node_modules/redoc-cli/node_modules/tslib/tslib.js:136:27)
    at Object.next (/usr/lib/node_modules/redoc-cli/node_modules/tslib/tslib.js:117:57)
    at fulfilled (/usr/lib/node_modules/redoc-cli/node_modules/tslib/tslib.js:107:62)

Any idea?

@steffes
Copy link
Author

steffes commented Feb 21, 2020

common.yaml is not valid swagger: 2.0. title, version, and paths are required. Paths may be empty.

Using the https://mermade.org.uk/openapi-converter I got the following result that is missing the preexisting components:

openapi: 3.0.0
info:
  version: ""
  title: ""
paths: {}

components:
  securitySchemes:
    Bearer:
      type: JWT
      name: Authorization
      in: header
    BasicAuth:
      type: http
      scheme: basic
  schemas:
    ContainerNotFound:
      description: Not found
      schema:
        type: object
        properties:
          code:
            type: integer
            example: 404
          message:
            type: string
            example: Content container not found!

Need to figure out the proper conversion of components: parameters: and components: properties:. Know of any tools that do it?

When creating my client code, I bundle and dereference so I am skipping common.yaml because it's bundled.

@luke-
Copy link
Contributor

luke- commented Apr 7, 2020

Besides the common file problem, are you still able to generate the HTML documentation with your changes?

https://github.com/humhub/humhub-modules-rest/blob/master/docs/swagger/build-all.sh

@steffes
Copy link
Author

steffes commented Apr 9, 2020

No I get the same build error as you. All the files need to be refactored much more to be OpenAPI 3.0. I am closing this and will try to make a better PR with everything properly updated.

@steffes steffes closed this Apr 9, 2020
@luke-
Copy link
Contributor

luke- commented Apr 10, 2020

That would be awesome!

We don't necessarily have to use Redec to build the HTML documentation, but the SinglePages doc without any dependencies (JS/Images) was very convenient.

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

Successfully merging this pull request may close these issues.

2 participants