Skip to content

Commit

Permalink
Merge pull request #25 from jolicode/fix/example-schema
Browse files Browse the repository at this point in the history
fixed the /users/{userId}/teammates patch response example schema
  • Loading branch information
xavierlacot authored Nov 12, 2022
2 parents 196746e + 3bc38b9 commit fc42543
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
11 changes: 10 additions & 1 deletion generated/harvest-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3319,6 +3319,15 @@ components:
format: url
description: 'Next page'
nullable: true
TeammatesPatchResponse:
type: object
required:
- teammates
properties:
teammates:
type: array
items:
$ref: '#/components/schemas/Teammate'
security:
-
BearerAuth: []
Expand Down Expand Up @@ -12597,7 +12606,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/TeammatesPatchResponse'
example:
teammates:
-
Expand Down
12 changes: 12 additions & 0 deletions src/Dumper/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ public function dump(array $data): array
],
],
],
'TeammatesPatchResponse' => [
'type' => 'object',
'required' => ['teammates'],
'properties' => [
'teammates' => [
'type' => 'array',
'items' => [
'$ref' => '#/components/schemas/Teammate',
],
],
],
],
];
$warnings = [];

Expand Down
6 changes: 5 additions & 1 deletion src/Extractor/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ public static function guessFieldType($name, $objectName = null)
public static function guessPathResponseSchema($summary, $title)
{
$guesser = function ($summary) use ($title) {
if ('Update a user’s assigned teammates' === $summary) {
return '#/components/schemas/TeammatesPatchResponse';
}

if (preg_match('/^Create an? ([a-zA-Z ]+)/', $summary, $matches)) {
return '#/components/schemas/'.self::camelize($matches[1]);
}
Expand Down Expand Up @@ -841,7 +845,7 @@ private function printUnknownDefinitions(array $items)
} elseif ('$ref' === $key) {
$item = substr($item, 21);

if (!isset($this->definitions[$item]) && !\in_array($item, ['Error', 'InvoiceMessageSubjectAndBody'], true)) {
if (!isset($this->definitions[$item]) && !\in_array($item, ['Error', 'InvoiceMessageSubjectAndBody', 'TeammatesPatchResponse'], true)) {
throw new \LogicException(sprintf('Unknown definition: %s', $item));
}
}
Expand Down

0 comments on commit fc42543

Please sign in to comment.