schema-generator
schema-generator copied to clipboard
[enhancement] don't make abstract classes and embeddables api resources
Right now if I have this schema.yml
types:
Thing:
properties:
name: ~
Person:
properties:
familyName: ~
Country:
parent: false
embeddable: true
properties:
address: { range: "Text" }
PostalAddress:
parent: false
properties:
addressCountry: { range: "Country", embedded: true }
It will generate all the entities and all entities are marked as an api resource in the class annotations. The only problem is that you don't want Thing and Country to be api resources. Thing is an abstract class so it can't even be initialized. And since Country is an embeddable it isn't linked to any database table so you can never fetch any countries from the api.
You can disable some API resources (src/AppBundle/Resources/config/api_resources/resources.yml):
AppBundle\Entity\Thing:
collectionOperations: {}
itemOperations: {}
...
Sorry for bumping this old issue.
Am I correct in assuming that setting a class as abstract, at least in the past, prevented it from becoming an ApiResource?
https://github.com/api-platform/schema-generator/issues/159
It seems that this is no longer the case. I have been helping myself with
attributes:
- ApiResource: { operations: [ ] }
Is it "ok" to do it this way or is it rather not so good?