api-platform / api-platform/schema-generator

Error 'Class "PostalAddress" does not exist' is been shown in the ApiPlatform's swagger after generating ODM documents

Đang mở
#403 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
474
Fork
107
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**API Platform version(s) affected**: 3.1.10

**Description**
I ran the generate command to generate ODM documents from a schema configuration that had two types one of them has a reference to the other one. After the documents got generated I tried to go to API Platform's API documentation and saw this error:
"Class "PostalAddress" does not exist".

**How to reproduce**
In an API Platform project that supports MongoDB add this configuration file:

```
# config/schema.yaml
openApi:
file: null
types:
Person:
properties:
name: ~
address: { range: https://schema.org/PostalAddress }
PostalAddress:
properties:
streetAddress: ~

namespaces:
entity: 'App\Document'
enum: 'App\Enum'
interface: 'App\Model'
annotationGenerators:
- ApiPlatform\SchemaGenerator\AnnotationGenerator\PhpDocAnnotationGenerator
attributeGenerators:
- ApiPlatform\SchemaGenerator\AttributeGenerator\ConstraintAttributeGenerator
- ApiPlatform\SchemaGenerator\AttributeGenerator\DoctrineMongoDBAttributeGenerator
- ApiPlatform\SchemaGenerator\AttributeGenerator\ApiPlatformCoreAttributeGenerator
- ApiPlatform\SchemaGenerator\AttributeGenerator\ConfigurationAttributeGenerator

debug: true
useInterface: false
checkIsGoodRelations: true
id:
generationStrategy: mongoid
```

and then run this command:
```
/vendor/bin/schema generate src/ config/schema.yaml
```

**Possible Solution**
The method `getRelationName` in class `ApiPlatform\SchemaGenerator\AttributeGenerator\DoctrineMongoDBAttributeGenerator` can have the logic to add the namespace of the reference class. currently, it returns only the name of the class. Something like the same method in class `ApiPlatform\SchemaGenerator\AttributeGenerator\DoctrineOrmAttributeGenerator`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.