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

Can you add one JSON_FORCE_OBJECT property in ApiProblemResponse jsonFlags #1

Open
weierophinney opened this issue Dec 31, 2019 · 4 comments

Comments

@weierophinney
Copy link
Contributor

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',
)

Originally posted by @developer-devPHP at zfcampus/zf-api-problem#56

@weierophinney
Copy link
Contributor Author

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


Originally posted by @developer-devPHP at zfcampus/zf-api-problem#56 (comment)

@weierophinney
Copy link
Contributor Author

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


Originally posted by @developer-devPHP at zfcampus/zf-api-problem#56 (comment)

@weierophinney
Copy link
Contributor Author

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


Originally posted by @developer-devPHP at zfcampus/zf-api-problem#56 (comment)

@weierophinney
Copy link
Contributor Author

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


Originally posted by @NicolasCayet at zfcampus/zf-api-problem#56 (comment)

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