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

Support for OpenAPI Links? #615

Open
fsabr opened this issue Dec 10, 2020 · 2 comments
Open

Support for OpenAPI Links? #615

fsabr opened this issue Dec 10, 2020 · 2 comments

Comments

@fsabr
Copy link

fsabr commented Dec 10, 2020

Is there support for OpenAPI Links? I couldn't find it anywhere.

Manually adding the following to the docstring works

links:
    Get User By Id:
        operationId: UserGet
        parameters:
            id: $response.body#/id

but I don't think the validation part works, as something like this

links:
    Get User By Id:
        operationId: UserGet
        parameters:
            id: RandomString

also validates (using apispec.utils.validate_spec).

@lafrech
Copy link
Member

lafrech commented Dec 10, 2020

Hi.

There is currently nothing in apispec to provide a link feature.

If it works by writing the link manually in the docstring, that's fine.

I can't look into it right now, but if there's anything apispec could do to make it less manual (and avoid typos), then suggestions are welcome.

The validation feature is just a wrapper to an external validator (prance). The fact that validation passes has nothing to do with apispec support but only with the parsers used by prance.

@mjpieters
Copy link
Contributor

See the Links section on swagger.io.

apispec could generate this, with a little help:

  • It has enough information to produce operationRef values if no operationId is available.
  • you'd need a way of mapping path parameters to schema fields

The latter is a lot easier if you are using a web server framework with plugins; e.g. you could mark up Marshmallow fields to mark them as identifiers, then link those with Flask-Smorest route parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants