diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..3a9251f --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: byjg diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..92f1f0e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,37 @@ +# Contributing to byjg/php-swagger-test + +First of all, thank you for taking the time to contribute! + +## How to Contribute + +### Issues + +If you encounter any issues, have questions, or need clarification, please open an issue on our [Issues page](https://github.com/your-repo/issues). This helps us track and prioritize bug fixes and enhancements. + +### Branches + +We have three main branches in this project: + +- **master**: Contains the latest code. It is generally stable, but we recommend using it with caution. +- **a.b**: Use this branch for creating PRs. The naming convention follows `a.b`, where `a` is the major release and `b` is the minor release of the current version. For example, if the current release is 4.9.2, use the branch `4.9` for your PR. You can also use `4.9.x-dev` in your composer for development purposes. +- **future release**: This branch is typically `(a+1).0`. For instance, if the current release is 4.9.2, the future release branch will be `5.0`. + + +### Code Style and Guidelines + +- **Follow PSR Standards**: We follow [PSR-1](https://www.php-fig.org/psr/psr-1/), [PSR-2](https://www.php-fig.org/psr/psr-2/), and [PSR-12](https://www.php-fig.org/psr/psr-12/). +- **Write Clear Commit Messages**: Use the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. +- **Documentation**: Update the documentation for any new features or changes. + +### Common Practices + +- **Keep Pull Requests Small**: Smaller PRs are easier to review and merge. Focus on one feature or fix per PR. +- **Write Tests**: Ensure your changes are covered by tests. We aim for a high level of test coverage. +- **Respect Reviewers' Time**: Be responsive to feedback and willing to make necessary changes. + +### Community + +- **Be Respectful**. +- **Collaborate**: We encourage collaboration and open discussion. Don’t hesitate to ask for help or provide feedback. + +Thank you for contributing to byjg/php-swagger-test! Your help is appreciated and makes a big difference. diff --git a/src/Base/Body.php b/src/Base/Body.php index 149a73c..a48a35c 100644 --- a/src/Base/Body.php +++ b/src/Base/Body.php @@ -414,6 +414,11 @@ protected function matchSchema($name, $schemaArray, $body) return true; } + // Match any object + if (count($schemaArray) === 1 && isset($schemaArray['type']) && $schemaArray['type'] === 'object') { + return true; + } + throw new GenericSwaggerException("Not all cases are defined. Please open an issue about this. Schema: $name"); } diff --git a/src/Base/Schema.php b/src/Base/Schema.php index e9a898e..e8fc21f 100644 --- a/src/Base/Schema.php +++ b/src/Base/Schema.php @@ -6,6 +6,7 @@ use ByJG\ApiTools\Exception\GenericSwaggerException; use ByJG\ApiTools\Exception\HttpMethodNotFoundException; use ByJG\ApiTools\Exception\InvalidDefinitionException; +use ByJG\ApiTools\Exception\InvalidRequestException; use ByJG\ApiTools\Exception\NotMatchedException; use ByJG\ApiTools\Exception\PathNotFoundException; use ByJG\ApiTools\OpenApi\OpenApiSchema; @@ -98,6 +99,9 @@ public function getPathDefinition($path, $method) $pathItemPattern = '~^' . preg_replace('~{(.*?)}~', '(?<\1>[^/]+)', $pathItem) . '$~'; $matches = []; + if (empty($uri->getPath())) { + throw new InvalidRequestException('The path is empty'); + } if (preg_match($pathItemPattern, $uri->getPath(), $matches)) { $pathDef = $this->jsonFile[self::SWAGGER_PATHS][$pathItem]; if (!isset($pathDef[$method])) {