Skip to content

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

@SDParish

Description

@SDParish

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.

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