Skip to content

Instantly share code, notes, and snippets.

@piotrbrzezina
Last active June 27, 2019 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrbrzezina/4151f8ef8105b2066adc4fbf71f91198 to your computer and use it in GitHub Desktop.
Save piotrbrzezina/4151f8ef8105b2066adc4fbf71f91198 to your computer and use it in GitHub Desktop.
Flashcard step 10
<?php
class SwaggerDecorator implements NormalizerInterface
{
private $decorated;
public function __construct(NormalizerInterface $decorated)
{
$this->decorated = $decorated;
}
public function normalize($object, $format = null, array $context = [])
{
$docs = $this->decorated->normalize($object, $format, $context);
$docs['paths']['/login'] = [
'post' => [
'tags' => ['login'],
'summary' => 'Login to app',
'parameters' => [
...
],
'responses' => [
...
]
]
];
return $docs;
}
public function supportsNormalization($data, $format = null)
{
return $this->decorated->supportsNormalization($data, $format);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment