Skip to content

Commit

Permalink
composer test
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2066 committed Dec 10, 2024
1 parent d18911a commit a68e7e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Swagger/SwaggerComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SwaggerComponents
public function __construct(
protected SwaggerCommon $common,
protected PropertyManager $propertyManager,
protected GenerateProxyClass $generateProxyClass,
protected ?GenerateProxyClass $generateProxyClass,
) {
}

Expand Down Expand Up @@ -57,7 +57,7 @@ public function getProperties(string $className): array
$propertyManager = $this->propertyManager->getProperty($className, $fieldName);

// 适配ApiVariable注解
$sourceClassName = $this->generateProxyClass->getSourceClassname($className) ?? $className;
$sourceClassName = $this->generateProxyClass?->getSourceClassname($className) ?? $className;
$apiModelProperty = ApiAnnotation::getProperty($sourceClassName, $fieldName, ApiModelProperty::class) ?: new ApiModelProperty();

/** @var In $inAnnotation */
Expand Down
4 changes: 1 addition & 3 deletions tests/SwaggerSchemasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\Di\MethodDefinitionCollector;
use Hyperf\Di\MethodDefinitionCollectorInterface;
use Hyperf\DTO\DtoCommon;
use Hyperf\DTO\Scan\PropertyEnum;
use Hyperf\DTO\Scan\PropertyManager;
use Hyperf\DTO\Scan\Scan;
use HyperfTest\ApiDocs\Request\Address;
use HyperfTest\ApiDocs\Request\DemoBodyRequest;
use Mockery as m;
Expand All @@ -39,7 +37,7 @@ public function testSchemas()
// dto
$container->shouldReceive('get')->with(MethodDefinitionCollectorInterface::class)->andReturn(new MethodDefinitionCollector());
$swaggerCommon = new SwaggerCommon();
$swaggerComponents = new SwaggerComponents($swaggerCommon,new PropertyManager($swaggerCommon,new PropertyEnum()));
$swaggerComponents = new SwaggerComponents($swaggerCommon, new PropertyManager($swaggerCommon, new PropertyEnum()), null);
$schemas = $swaggerComponents->generateSchemas($classname);
$properties = $schemas->properties;
$this->assertEquals($properties[0]->property, 'int');
Expand Down

0 comments on commit a68e7e0

Please sign in to comment.