-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi,
I've been trying to make a Rust wrapper of the clab-api-server to interact with containerlabs programmatically. As soon as I saw you had a swagger API description available I rushed and used the official OpenAPI code generation tool to do that.
Everything has been running smooth except for the API endpoint that allows executing commands on nodes and getting the result: /api/v1/labs/{lab_name}/exec
This endpoint can return either JSON or plain output based on the format query parameter. However, in the current swagger description, the result type seems to always be "string" for result code 200:
/api/v1/labs/{labName}/exec:
post:
consumes:
- application/json
description: Executes a command on nodes within a specific lab. Checks ownership.
Supports filtering by a single node name.
parameters:
[...]
produces:
- application/json
responses:
"200":
description: Plain text output (if format=plain)
schema:
type: stringThis makes the OpenAPI code generation tool expect only Strings and not JSON Objects as well. When a JSON object is received (exec?format=json), the generated code tries to parse it as a json string instead of a json object and fails.
I believe that you can describe different output schemas based on the media type: https://swagger.io/docs/specification/v3_0/describing-responses/
I assume that this is not a bug from OpenAPI and just an overlook in the api description but I might be wrong.