Skip to content

Commit

Permalink
Merge pull request #80 from byjg/4.9
Browse files Browse the repository at this point in the history
4.9
  • Loading branch information
byjg authored Jun 4, 2024
2 parents 0fee120 + 56d6651 commit 2029ffb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: byjg
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions src/Base/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
4 changes: 4 additions & 0 deletions src/Base/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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])) {
Expand Down

0 comments on commit 2029ffb

Please sign in to comment.