Skip to content

Impossible to export yaml files when there are several groups #76

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

Closed
benfonty opened this issue Apr 7, 2022 · 6 comments
Closed

Impossible to export yaml files when there are several groups #76

benfonty opened this issue Apr 7, 2022 · 6 comments
Labels
duplicate This issue or pull request already exists

Comments

@benfonty
Copy link
Contributor

benfonty commented Apr 7, 2022

Hello, I am trying to export several groups in yaml format.

Here is my plugin configuration:

openApi {
    outputDir.set(file("$buildDir/docs"))
    groupedApiMappings.set(["http://localhost:8080/xxx/v3/api-docs.yaml/XXX public API": "openapi-xxx-public-api.yaml",
                            "http://localhost:8080/xxx/v3/api-docs.yaml/XXX admin API": "openapi-xxx-admin-api.yaml"])
    waitTimeInSeconds.set(100)
    bootRun {
        jvmArgs = ["-Dspring.profiles.active=openapigeneration"]
    }
}

I got an error: > Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive

I presume this is because of val isYaml = url.toLowerCase().matches(Regex(".+[./]yaml$")) which doesn't work when using groupedApiMappings because of the format of the urls.

@bnasslahsen
Copy link
Contributor

@benfonty,

see the answer here #71

@bnasslahsen bnasslahsen added the duplicate This issue or pull request already exists label Apr 7, 2022
@benfonty
Copy link
Contributor Author

benfonty commented Apr 7, 2022

Hello,

I am not sure this is a duplicate of #71.

In my case I ask for yaml files, but the code that computes the asked format relies on a regexp that does not work if the url doesn't end by .yaml, which is the case when using groups. Here the plugin tries to json prettify a yaml file.

@bnasslahsen
Copy link
Contributor

@benfonty,

Are you able to provice a Provide a Minimal, Reproducible Example - with HelloController that reproduces the problem ?

benfonty added a commit to benfonty/springdoc-openapi-gradle-plugin that referenced this issue Apr 8, 2022
@benfonty
Copy link
Contributor Author

benfonty commented Apr 8, 2022

I cloned the repo and added a failing test.

I am not sure I will have time to propose a fix this morning but I will give it a try by monday.

@bnasslahsen bnasslahsen reopened this Apr 8, 2022
@benfonty
Copy link
Contributor Author

benfonty commented Apr 8, 2022

I found time to propose a PR to fix the problem.

It passed the unit tests I made and I also tested it "live" locally with the actual repo I had problem with.

@benfonty
Copy link
Contributor Author

Hello @bnasslahsen can you find time to review my pull request?

bnasslahsen added a commit that referenced this issue Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants