Skip to content

HyperlinkRelated creating invalid endpoint #240

Description

@Makistos

For some reason HyperlinkRelated seems to create an invalid endpoint with HyperlinkRelated which Flask rejects:

Exception has occurred: BuildError (note: full exception trace is shown but execution is paused at: api_GetMagazine) Could not build url for endpoint '/api/publishers' with values ['id']. Did you mean 'publishers' instead?

These are my models:

class MagazineSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Magazine
    id = ma.auto_field()
    name = ma.auto_field()
    publisher = ma.HyperlinkRelated(
        endpoint='/api/publishers')
class PublisherSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Publisher
    id = ma.auto_field()

And this is what that API looks like:

@app.route('/api/publishers/<id>', methods=['get'])
def api_GetPublisher(id: Any) -> Any:
    options = {}
    options['publisherId'] = id
    return GetPublisher(options)

This API works with curl.

And this is how I try to dump the results in GetPublisher:

schema = MagazineSchema()
retval = schema.dump(magazine)

Am I doing something wrong? I can't figure out what that could be. I tried both with AutoSchema and Schema and both give the same result.

Activity

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

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