Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare v6 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .jane-openapi
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ return [
'namespace' => 'CatFacts\Api',
'directory' => __DIR__ . '/generated/',
'date-format' => \DateTimeInterface::RFC3339_EXTENDED,
'client' => 'psr18',
];
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
"license": "MIT",
"require": {
"php": ">= 7.2",
"jane-php/open-api-runtime": "@dev",
"jane-php/open-api-runtime": "^6.0",
"symfony/http-client": "^4.3",
"nyholm/psr7": "^1.2"
},
"require-dev": {
"jane-php/open-api": "@dev",
"jane-php/open-api": "^6.0",
"friendsofphp/php-cs-fixer": "^2.15"
},
"autoload": {
"psr-4": {
"CatFacts\\": "src/",
"CatFacts\\Api\\": "generated/"
}
},
"scripts": {
"cs-fix": "php-cs-fixer fix",
"generate": "rm -r generated/* ; jane-openapi generate"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
18 changes: 4 additions & 14 deletions generated/Client.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
<?php

declare(strict_types=1);

/*
* This file has been auto generated by Jane,
*
* Do no edit it directly.
*/

namespace CatFacts\Api;

class Client extends \Jane\OpenApiRuntime\Client\Psr18Client
{
/**
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
*
* @return \CatFacts\Api\Model\Fact|\Psr\Http\Message\ResponseInterface|null
* @return null|\CatFacts\Api\Model\Fact|\Psr\Http\Message\ResponseInterface
*/
public function randomFact(string $fetch = self::FETCH_OBJECT)
{
return $this->executePsr7Endpoint(new \CatFacts\Api\Endpoint\RandomFact(), $fetch);
}

public static function create($httpClient = null)
{
if (null === $httpClient) {
$httpClient = \Http\Discovery\Psr18ClientDiscovery::find();
$plugins = [];
$plugins = array();
$uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://cat-fact.herokuapp.com');
$plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri);
$httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins);
}
$requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory();
$streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory();
$serializer = new \Symfony\Component\Serializer\Serializer(\CatFacts\Api\Normalizer\NormalizerFactory::create(), [new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode())]);

$serializer = new \Symfony\Component\Serializer\Serializer(array(new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \CatFacts\Api\Normalizer\JaneObjectNormalizer()), array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode(array('json_decode_associative' => true)))));
return new static($httpClient, $requestFactory, $serializer, $streamFactory);
}
}
}
29 changes: 8 additions & 21 deletions generated/Endpoint/RandomFact.php
Original file line number Diff line number Diff line change
@@ -1,49 +1,36 @@
<?php

declare(strict_types=1);

/*
* This file has been auto generated by Jane,
*
* Do no edit it directly.
*/

namespace CatFacts\Api\Endpoint;

class RandomFact extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7Endpoint
{
use \Jane\OpenApiRuntime\Client\Psr7EndpointTrait;

public function getMethod(): string
public function getMethod() : string
{
return 'GET';
}

public function getUri(): string
public function getUri() : string
{
return '/facts/random';
}

public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
{
return [[], null];
return array(array(), null);
}

public function getExtraHeaders(): array
public function getExtraHeaders() : array
{
return ['Accept' => ['application/json']];
return array('Accept' => array('application/json'));
}

/**
* {@inheritdoc}
*
*
* @return \CatFacts\Api\Model\Fact|null
* @return null|\CatFacts\Api\Model\Fact
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
if (200 === $status && mb_strpos($contentType, 'application/json') !== false) {
return $serializer->deserialize($body, 'CatFacts\\Api\\Model\\Fact', 'json');
}
}
}
}
Loading