-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reference in endpoint parameter schema (#126)
Fix reference in endpoint parameter schema
- Loading branch information
Showing
19 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/OpenApi/Tests/fixtures/model-type-reference/.jane-openapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
return [ | ||
'openapi-file' => __DIR__ . '/schema.json', | ||
'namespace' => 'Jane\OpenApi\Tests\Expected', | ||
'directory' => __DIR__ . '/generated', | ||
'use-fixer' => false, | ||
]; |
17 changes: 17 additions & 0 deletions
17
src/OpenApi/Tests/fixtures/model-type-reference/expected/Client.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected; | ||
|
||
class Client extends \Jane\OpenApiRuntime\Client\Psr7HttplugClient | ||
{ | ||
public static function create($httpClient = null) | ||
{ | ||
if (null === $httpClient) { | ||
$httpClient = \Http\Discovery\HttpClientDiscovery::find(); | ||
} | ||
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find(); | ||
$streamFactory = \Http\Discovery\StreamFactoryDiscovery::find(); | ||
$serializer = new \Symfony\Component\Serializer\Serializer(\Jane\OpenApi\Tests\Expected\Normalizer\NormalizerFactory::create(), array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode()))); | ||
return new static($httpClient, $messageFactory, $serializer, $streamFactory); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/OpenApi/Tests/fixtures/model-type-reference/expected/Model/Model.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected\Model; | ||
|
||
class Model | ||
{ | ||
/** | ||
* | ||
* | ||
* @var string | ||
*/ | ||
protected $foo; | ||
/** | ||
* | ||
* | ||
* @var string | ||
*/ | ||
protected $bar; | ||
/** | ||
* | ||
* | ||
* @return string | ||
*/ | ||
public function getFoo() : string | ||
{ | ||
return $this->foo; | ||
} | ||
/** | ||
* | ||
* | ||
* @param string $foo | ||
* | ||
* @return self | ||
*/ | ||
public function setFoo(string $foo) : self | ||
{ | ||
$this->foo = $foo; | ||
return $this; | ||
} | ||
/** | ||
* | ||
* | ||
* @return string | ||
*/ | ||
public function getBar() : string | ||
{ | ||
return $this->bar; | ||
} | ||
/** | ||
* | ||
* | ||
* @param string $bar | ||
* | ||
* @return self | ||
*/ | ||
public function setBar(string $bar) : self | ||
{ | ||
$this->bar = $bar; | ||
return $this; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/OpenApi/Tests/fixtures/model-type-reference/expected/Normalizer/ModelNormalizer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected\Normalizer; | ||
|
||
use Jane\JsonSchemaRuntime\Reference; | ||
use Symfony\Component\Serializer\Exception\InvalidArgumentException; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
class ModelNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface | ||
{ | ||
use DenormalizerAwareTrait; | ||
use NormalizerAwareTrait; | ||
public function supportsDenormalization($data, $type, $format = null) | ||
{ | ||
return $type === 'Jane\\OpenApi\\Tests\\Expected\\Model\\Model'; | ||
} | ||
public function supportsNormalization($data, $format = null) | ||
{ | ||
return get_class($data) === 'Jane\\OpenApi\\Tests\\Expected\\Model\\Model'; | ||
} | ||
public function denormalize($data, $class, $format = null, array $context = array()) | ||
{ | ||
if (!is_object($data)) { | ||
throw new InvalidArgumentException(); | ||
} | ||
$object = new \Jane\OpenApi\Tests\Expected\Model\Model(); | ||
if (property_exists($data, 'foo')) { | ||
$object->setFoo($data->{'foo'}); | ||
} | ||
if (property_exists($data, 'bar')) { | ||
$object->setBar($data->{'bar'}); | ||
} | ||
return $object; | ||
} | ||
public function normalize($object, $format = null, array $context = array()) | ||
{ | ||
$data = new \stdClass(); | ||
if (null !== $object->getFoo()) { | ||
$data->{'foo'} = $object->getFoo(); | ||
} | ||
if (null !== $object->getBar()) { | ||
$data->{'bar'} = $object->getBar(); | ||
} | ||
return $data; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/OpenApi/Tests/fixtures/model-type-reference/expected/Normalizer/NormalizerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected\Normalizer; | ||
|
||
class NormalizerFactory | ||
{ | ||
public static function create() | ||
{ | ||
$normalizers = array(); | ||
$normalizers[] = new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(); | ||
$normalizers[] = new ModelNormalizer(); | ||
return $normalizers; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/OpenApi/Tests/fixtures/model-type-reference/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"version": "", | ||
"title": "" | ||
}, | ||
"paths": {}, | ||
"components": { | ||
"schemas": { | ||
"Model": { | ||
"type": "object", | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/components/schemas/Foo" | ||
}, | ||
"bar": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"Foo": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/OpenApi/Tests/fixtures/parameter-type-reference/.jane-openapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
return [ | ||
'openapi-file' => __DIR__ . '/schema.json', | ||
'namespace' => 'Jane\OpenApi\Tests\Expected', | ||
'directory' => __DIR__ . '/generated', | ||
'use-fixer' => false, | ||
]; |
31 changes: 31 additions & 0 deletions
31
src/OpenApi/Tests/fixtures/parameter-type-reference/expected/Client.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected; | ||
|
||
class Client extends \Jane\OpenApiRuntime\Client\Psr7HttplugClient | ||
{ | ||
/** | ||
* caca | ||
* | ||
* @param array $queryParameters { | ||
* @var string $bar | ||
* } | ||
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) | ||
* | ||
* @return null|\Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function foo(array $queryParameters = array(), string $fetch = self::FETCH_OBJECT) | ||
{ | ||
return $this->executePsr7Endpoint(new \Jane\OpenApi\Tests\Expected\Endpoint\Foo($queryParameters), $fetch); | ||
} | ||
public static function create($httpClient = null) | ||
{ | ||
if (null === $httpClient) { | ||
$httpClient = \Http\Discovery\HttpClientDiscovery::find(); | ||
} | ||
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find(); | ||
$streamFactory = \Http\Discovery\StreamFactoryDiscovery::find(); | ||
$serializer = new \Symfony\Component\Serializer\Serializer(\Jane\OpenApi\Tests\Expected\Normalizer\NormalizerFactory::create(), array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode()))); | ||
return new static($httpClient, $messageFactory, $serializer, $streamFactory); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/OpenApi/Tests/fixtures/parameter-type-reference/expected/Endpoint/Foo.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected\Endpoint; | ||
|
||
class Foo extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7Endpoint | ||
{ | ||
/** | ||
* caca | ||
* | ||
* @param array $queryParameters { | ||
* @var string $bar | ||
* } | ||
*/ | ||
public function __construct(array $queryParameters = array()) | ||
{ | ||
$this->queryParameters = $queryParameters; | ||
} | ||
use \Jane\OpenApiRuntime\Client\Psr7EndpointTrait; | ||
public function getMethod() : string | ||
{ | ||
return 'GET'; | ||
} | ||
public function getUri() : string | ||
{ | ||
return '/foo'; | ||
} | ||
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array | ||
{ | ||
return array(array(), null); | ||
} | ||
protected function getQueryOptionsResolver() : \Symfony\Component\OptionsResolver\OptionsResolver | ||
{ | ||
$optionsResolver = parent::getQueryOptionsResolver(); | ||
$optionsResolver->setDefined(array('bar')); | ||
$optionsResolver->setRequired(array('bar')); | ||
$optionsResolver->setDefaults(array()); | ||
$optionsResolver->setAllowedTypes('bar', array('string')); | ||
return $optionsResolver; | ||
} | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* | ||
* @return null | ||
*/ | ||
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) | ||
{ | ||
return null; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...OpenApi/Tests/fixtures/parameter-type-reference/expected/Normalizer/NormalizerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected\Normalizer; | ||
|
||
class NormalizerFactory | ||
{ | ||
public static function create() | ||
{ | ||
$normalizers = array(); | ||
$normalizers[] = new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(); | ||
return $normalizers; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/OpenApi/Tests/fixtures/parameter-type-reference/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"version": "", | ||
"title": "" | ||
}, | ||
"paths": { | ||
"/foo": { | ||
"get": { | ||
"operationId": "foo", | ||
"description": "caca", | ||
"parameters": [ | ||
{ | ||
"name": "bar", | ||
"in": "query", | ||
"schema": { | ||
"$ref": "#/components/schemas/Bar" | ||
}, | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"default": { | ||
"description": "Default response" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Bar": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/OpenApi/Tests/fixtures/response-type-reference/.jane-openapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
return [ | ||
'openapi-file' => __DIR__ . '/schema.json', | ||
'namespace' => 'Jane\OpenApi\Tests\Expected', | ||
'directory' => __DIR__ . '/generated', | ||
'use-fixer' => false, | ||
]; |
26 changes: 26 additions & 0 deletions
26
src/OpenApi/Tests/fixtures/response-type-reference/expected/Client.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Jane\OpenApi\Tests\Expected; | ||
|
||
class Client extends \Jane\OpenApiRuntime\Client\Psr7HttplugClient | ||
{ | ||
/** | ||
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) | ||
* | ||
* @return null|\Jane\OpenApi\Tests\Expected\Model\FooGetResponse200|\Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function foo(string $fetch = self::FETCH_OBJECT) | ||
{ | ||
return $this->executePsr7Endpoint(new \Jane\OpenApi\Tests\Expected\Endpoint\Foo(), $fetch); | ||
} | ||
public static function create($httpClient = null) | ||
{ | ||
if (null === $httpClient) { | ||
$httpClient = \Http\Discovery\HttpClientDiscovery::find(); | ||
} | ||
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find(); | ||
$streamFactory = \Http\Discovery\StreamFactoryDiscovery::find(); | ||
$serializer = new \Symfony\Component\Serializer\Serializer(\Jane\OpenApi\Tests\Expected\Normalizer\NormalizerFactory::create(), array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode()))); | ||
return new static($httpClient, $messageFactory, $serializer, $streamFactory); | ||
} | ||
} |
Oops, something went wrong.