From 50d71ffd42e3a2b51b393c77cfc0584f92349e1e Mon Sep 17 00:00:00 2001 From: KEL Date: Wed, 15 Sep 2021 17:12:30 +0800 Subject: [PATCH 1/2] fix: responseFile convert empty object to array responseFile convert empty object to array due to `json_decode($content, true)` Example ```json {"foo":{}} ``` convert to ```json {"foo":[]} ``` --- src/Extracting/Strategies/Responses/UseResponseFileTag.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Extracting/Strategies/Responses/UseResponseFileTag.php b/src/Extracting/Strategies/Responses/UseResponseFileTag.php index 007f4fc1..8cf585f3 100644 --- a/src/Extracting/Strategies/Responses/UseResponseFileTag.php +++ b/src/Extracting/Strategies/Responses/UseResponseFileTag.php @@ -62,7 +62,12 @@ protected function getFileResponses(array $tags) } $status = $result[1] ?: 200; $content = $result[2] ? file_get_contents($filePath, true) : '{}'; - $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; + + if (empty($result[3])) { + return ['content' => $content, 'status' => (int) $status]; + } + + $json = str_replace("'", '"', $result[3]); $merged = array_merge(json_decode($content, true), json_decode($json, true)); return ['content' => json_encode($merged), 'status' => (int) $status]; From 4775d5dbad0ca69a7e73c728f2a968da9f110c42 Mon Sep 17 00:00:00 2001 From: KEL Date: Mon, 13 Jan 2025 17:04:09 +0800 Subject: [PATCH 2/2] Add code review guidelines and process --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/deathkel/laravel-apidoc-generator?shareId=XXXX-XXXX-XXXX-XXXX). --- CODE_REVIEW.md | 41 +++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 12 ++++++++++++ README.md | 3 +++ 3 files changed, 56 insertions(+) create mode 100644 CODE_REVIEW.md diff --git a/CODE_REVIEW.md b/CODE_REVIEW.md new file mode 100644 index 00000000..301caa9c --- /dev/null +++ b/CODE_REVIEW.md @@ -0,0 +1,41 @@ +# Code Review Guidelines + +## Code Review Process + +1. **Create a Pull Request**: When you have completed a feature or bug fix, create a pull request (PR) to the main branch. +2. **Assign Reviewers**: Assign at least one reviewer to your PR. Preferably, choose someone who is familiar with the codebase. +3. **Review the Code**: The assigned reviewer(s) will review the code, checking for functionality, readability, and adherence to coding standards. +4. **Address Feedback**: If the reviewer(s) request changes, address the feedback and update the PR. +5. **Approval and Merge**: Once the reviewer(s) approve the PR, it can be merged into the main branch. + +## Best Practices + +- **Write Clear and Concise Code**: Ensure your code is easy to read and understand. +- **Follow Coding Standards**: Adhere to the project's coding standards and guidelines. +- **Test Your Code**: Write unit tests for your code and ensure all tests pass before submitting a PR. +- **Keep PRs Small**: Submit small, focused PRs that are easier to review. +- **Provide Context**: Include a clear description of the changes in your PR and any relevant context. + +## Common Issues + +- **Lack of Tests**: Ensure your code is well-tested. +- **Poor Naming Conventions**: Use meaningful and descriptive names for variables, functions, and classes. +- **Inconsistent Formatting**: Follow the project's formatting guidelines. +- **Large PRs**: Break down large PRs into smaller, more manageable ones. +- **Lack of Documentation**: Document your code and provide comments where necessary. + +## Examples of Good and Bad Code Reviews + +### Good Code Review + +- **Positive Feedback**: "Great job on this feature! The code is clean and well-organized." +- **Constructive Criticism**: "I noticed a potential issue with the error handling. Could you add a check for null values?" +- **Suggestions for Improvement**: "Consider using a more descriptive variable name here to improve readability." + +### Bad Code Review + +- **Negative Feedback**: "This code is terrible. You need to rewrite it." +- **Unclear Comments**: "Fix this." +- **Lack of Specificity**: "This needs improvement." + +By following these guidelines, we can ensure a smooth and effective code review process that helps maintain the quality of our codebase. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9234426e..de47066d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,3 +47,15 @@ Before submitting a pull request: - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. **Happy coding**! + +## Code Review Guidelines + +When submitting a pull request, please follow these code review guidelines: + +1. **Create a Pull Request**: When you have completed a feature or bug fix, create a pull request (PR) to the main branch. +2. **Assign Reviewers**: Assign at least one reviewer to your PR. Preferably, choose someone who is familiar with the codebase. +3. **Review the Code**: The assigned reviewer(s) will review the code, checking for functionality, readability, and adherence to coding standards. +4. **Address Feedback**: If the reviewer(s) request changes, address the feedback and update the PR. +5. **Approval and Merge**: Once the reviewer(s) approve the PR, it can be merged into the main branch. + +By following these guidelines, we can ensure a smooth and effective code review process that helps maintain the quality of our codebase. diff --git a/README.md b/README.md index f5c6ed8f..82ee540f 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,9 @@ $app->configure('apidoc'); ## Documentation Check out the documentation at the [Beyond Code homepage](https://beyondco.de/docs/laravel-apidoc-generator/). +## Code Review Process +We have a code review process in place to ensure the quality and consistency of our codebase. Please refer to the [Code Review Guidelines](CODE_REVIEW.md) for more information. + ### License The Laravel API Documentation Generator is free software licensed under the MIT license.