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

Initial version #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Initial version #1

wants to merge 4 commits into from

Conversation

Farcasut
Copy link

@Farcasut Farcasut commented Jan 16, 2025

Initial commit:

  1. Added the Swagger Macro, translations, and a proxy to avoid CORS issues.
  2. Swagger Macro.
  3. Translations.
  4. Proxy to avoid CORS issues, with specific handling for private GitHub, GitLab, and Bitbucket resources.

* Documentation & Downloads: [Documentation & Download](https://extensions.xwiki.org/xwiki/bin/view/Extension/(extension name)))
* [Issue Tracker](https://jira.xwiki.org/browse/(jira id)
* Project Lead: [Farcasi Alexandru](https://www.xwiki.org/xwiki/bin/view/XWiki/Farcasut)
* Documentation & Downloads: [Documentation & Download](https://extensions.xwiki.org/xwiki/bin/view/Extension/(extension name))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad link

Copy link
Author

@Farcasut Farcasut Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add the right link after the first release
image

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
import javax.inject.Singleton;

import org.xwiki.component.annotation.Component;
import org.xwiki.contrib.swagger.internal.Proxy;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't import internal components in public ones.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import internal components in public ones

That's not a problem. What is a problem is exposing internal classes in public APIs.

* @throws IOException
* @throws URISyntaxException
*/
public String executeProxy(String url, String accessToken, String password, String username)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a method that can call sent requests to different domains and each domain needs different params. I think it would have been better to accept a map parameter rather than have a bunch of nullable parameters.

rendering.macro.swagger.parameter.supportedSubmitMethods.description=List the operations allowed in 'Try it out', separated by commas: get, post, put, delete, head, options, patch, trace. To disable 'Try it out' completely, enter none
rendering.macro.swagger.parameter.supportedSubmitMethods.name=Supported submit methods
rendering.macro.swagger.parameter.tagsSorter.description=Definition order (default), name (alpha)
rendering.macro.swagger.parameter.tagsSorter.name=Tags Sorter
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


function checkIfJson(content) {
// We know that all json start with "{" so we can check if the first character is "{".
return content.charAt(0) === "{";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a more robust method of checking it would be to JSON.parse it

swagger-api/pom.xml Outdated Show resolved Hide resolved
swagger-api/pom.xml Outdated Show resolved Hide resolved
swagger-api/pom.xml Outdated Show resolved Hide resolved
import javax.inject.Singleton;
import javax.ws.rs.core.UriBuilder;

import org.apache.http.client.methods.CloseableHttpResponse;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to use HTTPClient 5 instead of 4.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! @tmortagne I might be wrong, but XWiki 14.10 depends on HttpClient 4.5, and HttpClient 5 was introduced in HttpClient 5.x

Copy link
Member

@tmortagne tmortagne Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XWiki 14.10 does not embed HTTPClient 5, but it does have a dependency management for it (it's using it during the build) and more recent versions of XWiki embed it. Depending on HTTPClient 5 just means that it will be installed along with your extension (which should not be a problem) in XWiki 14.10 version until the version of XWiki which is embedding it (in which case it will just reuse whatever is already there).

It's just that if when you start doing HTTP stuff now, it's better to get the reflex to do it with the latest version of Apache HTTPClient, one less upgrade later.

swagger-macro/pom.xml Outdated Show resolved Hide resolved
@Component
@Named("swagger")
@Singleton
@Unstable
Copy link
Member

@tmortagne tmortagne Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, unless you have in your projct a strict policy regarding unstable API and know where to remove them (like we have in XWiki Standard, but which is very rare in contrib projects), I'm not sure using the @Unstable annotation in contrib extensions makes that much sense (the problem is that there is a good chance it stays there forever).

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.

3 participants