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

(Auto)generate documentation #71

Open
guusdk opened this issue Dec 18, 2021 · 13 comments
Open

(Auto)generate documentation #71

guusdk opened this issue Dec 18, 2021 · 13 comments
Assignees

Comments

@guusdk
Copy link
Member

guusdk commented Dec 18, 2021

The documentation that's provided with this plugin seems to be generated from the code. We should document how this is done. Ideally, it's automatically re-generated when the plugin is build (mvn clean package).

guusdk added a commit to guusdk/openfire-restAPI-plugin that referenced this issue Jan 7, 2022
This commit introduces an automatically generated Swagger-based REST client on /plugins/restapi/docs/index.html

Note that this can't be used 'offline'. We still need to replace the static documentation (in readme.html) with something that's generated during compilation/packaging (issue igniterealtime#71)
guusdk added a commit to guusdk/openfire-restAPI-plugin that referenced this issue Jan 13, 2022
This commit introduces an automatically generated Swagger-based REST client on /plugins/restapi/docs/index.html

Note that this can't be used 'offline'. We still need to replace the static documentation (in readme.html) with something that's generated during compilation/packaging (issue igniterealtime#71)
guusdk added a commit to guusdk/openfire-restAPI-plugin that referenced this issue Jan 13, 2022
This commit introduces an automatically generated Swagger-based REST client on /plugins/restapi/docs/index.html

Note that this can't be used 'offline'. We still need to replace the static documentation (in readme.html) with something that's generated during compilation/packaging (issue igniterealtime#71)
Redor pushed a commit that referenced this issue Jan 16, 2022
* fixes #67: Migrate to Jersey 2

This updates the Jersey dependency from 1.x to 2.x.

This commit requires OF-2352 / igniterealtime/Openfire#1945 which means that this PR will _not_ work with 4.7.0 beta (but hopefully will with 4.7.0 non-beta).

* fixes #1: Migrate to Swagger

This commit introduces an automatically generated Swagger-based REST client on /plugins/restapi/docs/index.html
Note that this can't be used 'offline'. We still need to replace the static documentation (in readme.html) with something that's generated during compilation/packaging (issue #71)

* Add Swagger annotations to document endpoints

By adding certain annotations, the documentation as generated by Swagger becomes enriched.

* Add JsonProperty matching XmlElementWrapper name
* Add JsonProperty annotation for a user's groupnames

Co-authored-by: Dan Caseley <[email protected]>
@ruicaramalho
Copy link

Hi what's the URL to get the Swagger Documentation?

@Fishbowler
Copy link
Member

Based on the AuthFilter, looks to be at /plugins/restapi/v1/openapi.yaml

@ruicaramalho
Copy link

Im missing something..
If I try to open it in the browser it will treat .yaml as a file and download it.

PS -It does work if I open the index file:///C:/Program%20Files/Openfire/plugins/restapi/web/docs/index.html

@Fishbowler
Copy link
Member

You're right.

I've just had a quick test on my local docker environment. After installation, there's a link in the settings.
image
That links to /plugins/restapi/docs/index.html which opens the view you're looking for.

@ruicaramalho
Copy link

ruicaramalho commented Apr 11, 2022

Thanks @Fishbowler .

The only thing that could be improved is that the swagger URL by default is `http://localhost:9090/plugins/restapi/v1/openapi.yaml'

image

It should have gotten the current location and port, in Javascript window.location.origin in my case:

image

@GregDThomas
Copy link
Contributor

FWIW, a relative URL may well work, e.g. /plugins/restapi/v1/openapi.yaml (or even ../v1/openapi.yaml) (not tried either - but based on experience in other Swagger APIs

@ruicaramalho
Copy link

Thanks @GregDThomas but it does not work, it suggests downloading the file

@Fishbowler
Copy link
Member

The only thing that could be improved is that the swagger URL by default is `http://localhost:9090/plugins/restapi/v1/openapi.yaml'

The location linked to from the settings page?

If so, I'll raise an issue.

(btw, you blanked your domain from the address bar, but not from your image, but these posts are editable if you care about keeping it unknown)

@ruicaramalho
Copy link

Solution:

Edit the index file and change to:

.......
<script>
    window.onload = function() {
        // Begin Swagger UI call region
        const ui = SwaggerUIBundle({
            url: window.location.origin+"/plugins/restapi/v1/openapi.yaml",
            dom_id: '#swagger-ui',
            deepLinking: true,
            presets: [
                SwaggerUIBundle.presets.apis,
                SwaggerUIStandalonePreset
            ],
            plugins: [
                SwaggerUIBundle.plugins.DownloadUrl
            ],
            layout: "StandaloneLayout"
        });
        // End Swagger UI call region

        window.ui = ui;
    };
</script>
......

Originaly it was:

........
<script>
    window.onload = function() {
        // Begin Swagger UI call region
        const ui = SwaggerUIBundle({
            url: "http://localhost:9090/plugins/restapi/v1/openapi.yaml",
            dom_id: '#swagger-ui',
            deepLinking: true,
            presets: [
                SwaggerUIBundle.presets.apis,
                SwaggerUIStandalonePreset
            ],
            plugins: [
                SwaggerUIBundle.plugins.DownloadUrl
            ],
            layout: "StandaloneLayout"
        });
        // End Swagger UI call region

        window.ui = ui;
    };
</script>
........

@Fishbowler
Copy link
Member

Ah yep. Got it.

url: "http://localhost:9090/plugins/restapi/v1/openapi.yaml",

@ruicaramalho
Copy link

Thanks... it's fixed then :)

@ruicaramalho
Copy link

Hi
Does this means, that this feature will be corrected in future versions?

PS -Sorry but I don't know how the GitHub works.

@ruicaramalho
Copy link

ruicaramalho commented Apr 13, 2022

Hi @guusdk.

what I mean is if the index.html is going to be corrected.

url: "http://localhost:9090/plugins/restapi/v1/openapi.yaml",

To: url: window.location.origin+"/plugins/restapi/v1/openapi.yaml",

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

5 participants