Skip to content

Conversation

@Sebeia
Copy link

@Sebeia Sebeia commented Dec 31, 2025

Hello @jgoclawski. At Semeia-io we use socialwifi jsonapi-requests. We picked it due to its simplicity of use. We thank you very much for the work 💯 !

We use a slightly modified version of your work that enables our python services to interact with our rails API via the ORM part. These services are using Flask, and connect to the API on a user specific base via an authentication forwarding mechanism.

Our additions to the original work aim at enabling two features the way we use them:

  • Being able to create the ORM objects without prior definition of the api with its authentication method
  • Being able to generate valid JsonAPI query strings based on the objects specified as fields within the API.

Inside this first submission is the code that enables us to do the first point.

The base principle is to subclass ApiModel with a new DeferredAuthApiModel for which we rewrite a metaclass object to delay the options creation via the OptionsFactory.get usage to the __call__ stage of this new metaclass.
This modification goes hand in hand with an interface contract specifying that any subclass implementing the DeferredAuthApiModel must implement the api classmethod itself.
This is verified at metaclass __call__ time as well, and will raise a NotImplementedError in case this classmethod is not present on the child class.

I can open a second PR with the modifications that enable us to build query strings programmatically based on Fields.

@Sebeia Sebeia force-pushed the defer-auth-to-apimodel-init branch from 2fbb410 to 97a6406 Compare December 31, 2025 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant