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

Propose that a Model class should have a function to generate/populate from an array/stdClass (from a response) #7

Open
SDParish opened this issue Nov 6, 2020 · 0 comments

Comments

@SDParish
Copy link

SDParish commented Nov 6, 2020

The sendWith() function in a Request class calls SwaggerClient::make() with a list of valid Model names per response code, and expects to get back an instance of one of these.
When the make() function is manually written in the implementation of the SwaggerClient, the author needs to add code to go through each setter on the Model to set its value from the data they have after doing the request (typically the response after making the request). The make() function needs to do this (or link to code doing this) for all Models it may have to return, all of which currently needs to be written manually (or at least is not provided by this repository).
Given it should be the output of the API, this data should be in a standard format per Model, with property fields as in the swagger file and used by this repository to generate the Model.

As such I am proposing that each Model class gets a 'generate'/'populate' function of some kind that takes in a stdClass/other data store, and for each of the keys defined in the swagger file, if present in the provided data store, sets the matching field in the Model to that value. The make() function can then use that function, that will get regenerated with the Model if say the swagger file/Model changes, to put the data from the response into an instance of the Model.

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

No branches or pull requests

1 participant