Is it possible to retrieve response schema?

Hello!

I’d like to consume web-api of SQ server via Golang and can’t find any ready library for that. I decided to create one.

The /api/webservices/list endpoint looks good to fetch the api definition and generate a client, but there are no schema for a response.
Is it possible to get via web-api a schema for response somehow in machine-readable view? (Similar to /api/webservices/response_example but schema). JSON Schema would be perfect, but any format that allows to generate client library code will be fine.

Hi Anton,

No, SonarQube doesn’t provide a machine-readable web api schema.

Do you have good examples where we could get an inspiration?

Thanks!

Do you have good examples where we could get an inspiration?

No, unfortunately, I can’t provide an example from some project.

As I can see, you are using protobuf for generation your web-services (e.g. https://github.com/SonarSource/sonarqube/blob/2b0f05f4442cb3e3b9c798adf9d93f64e19a6b01/sonar-ws/src/main/protobuf/ws-projects.proto#L50 )?
Maybe it is possible to add one more endpoint to your API (or extend existing /api/webservices/list ) to return information about response format in json schema format (https://json-schema.org/)?

One of the simple solutions - convert your *.proto files to JSONSchema and serve them as static files as you are doing with response_examples (e.g. https://github.com/SonarSource/sonarqube/blob/2b0f05f4442cb3e3b9c798adf9d93f64e19a6b01/server/sonar-server/src/main/resources/org/sonar/server/ws/ws/response_example-example.json).
Quick googling brought me to this tools:

but I haven’t used them …

Off course, you may do this in runtime, but I’m not a Java-guy, so no tips from me in this question :-).

Alternative solution - maybe you have another network API, such as gRPC (since you are using proto-files)? This would be better for me as I won’t need to create a client library.

Thanks for the suggestion! We’ll discuss it internally within the team.

No, we don’t have another network API.

Thank you!
It would be nice if you share your team plans related to adding this feature after you discussed.
I will adjust my tasks according to your decision.

P. S. After some digging up I’ve found that adding type to incoming parameters would be useful as well, but not so critical as a schema of response.