Skip to content

Support for external json-schema ref #2165

Description

@Gara-Dorta

Is your feature request related to a problem? Please describe.

I have two repositories, signal-cli and signal-cli-rest-api.

signal-cli produces several json-schema files for a very complex API endpoint that signal-cli-rest-api exposes and does not modify. Right now, I have to manually adjust the output of swag init to add the json-schema definition from signal-cli.

Here is the scrip that it I use for that bbernhard/signal-cli-rest-api@master...Gara-Dorta:signal-cli-rest-api:receive-swagger#diff-7d11d0ae8d3cc5d45a8f408f8093e6d8895f07c6abd2a7599420137ede61a258

Describe the solution you'd like

I would like to have an annotation that supports an external ref file:

// @Success 201 {external-object} MessageEnvelope

Then I would like to be able to pass the file with the definition of MessageEnvelope to the init

swag init --external-file MessageEnvelope.json

The definition of MessageEnvelope would then be copied from the file.

Describe alternatives you've considered

As mentioned above, I've considered manually editing the output of swag but this is fragile and adds unnecessary extra work.

I also considered adding the annotations to signal-cli-rest-api but that would produce a lot of code duplication and add maintenance burden as new fields get added or removed to the end point in signal-cli.

Additional context

To highlight the complexity of the API, here are the json-schema files that signal-cli generates https://github.com/signalbot-org/signalbot/tree/3913ad73a3d08bc7029703b9a2430a111e75a2ef/src/signalbot/api/json_schema_receive

In these repos, the json-schema definitions are split across several files. I think adding support for cross file refs would add a lot of extra complexity. So I'd still be very happy if this is restricted to a single file with everything defined as swag would expect it. So that from swag perspective is just about copying the definition verbatim from the external file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions