Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Can you add one JSON_FORCE_OBJECT property in ApiProblemResponse jsonFlags #56

Open
tigran-m-dev opened this issue Mar 17, 2017 · 5 comments

Comments

@tigran-m-dev
Copy link

In your current code ApiProblemResponse class have this constructor

public function __construct(ApiProblem $apiProblem)
    {
        $this->apiProblem = $apiProblem;
        $this->setCustomStatusCode($apiProblem->status);
        $this->setReasonPhrase($apiProblem->title);
        $this->jsonFlags = JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR;
    }

Could you please add one more property in jsonFlags JSON_FORCE_OBJECT

Like this

public function __construct(ApiProblem $apiProblem)
    {
        $this->apiProblem = $apiProblem;
        $this->setCustomStatusCode($apiProblem->status);
        $this->setReasonPhrase($apiProblem->title);
        $this->jsonFlags = JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_FORCE_OBJECT;
    }

This will give api response to send non associated arrays keys for example during validation message generation, when keys are number and not string

like this

array(
3 =>'message1',
5 =>'message2',
7 =>'message3',
)
@tigran-m-dev
Copy link
Author

@weierophinney If you have a moment, please have a look to this.
I think this would be helpful for others too.

@tigran-m-dev
Copy link
Author

Can someone have a look on this and tell me can this changes part of new version?

@tigran-m-dev
Copy link
Author

any updates @weierophinney ?
If you want I can create this simple changes and did a pull request.

@NicolasCayet
Copy link

@developer-devPHP have you already prepare a PR for this ? It would be helpful here too

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas-api-tools/api-tools-api-problem; a new issue has been opened at laminas-api-tools/api-tools-api-problem#1.

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

No branches or pull requests

3 participants