api-platform / schema-generator

PHP Model Scaffolding from Schema.org and other RDF vocabularies
https://api-platform.com/docs/schema-generator/
MIT License
458 stars 108 forks source link

Enum Class Generation for schema.org/OrderStatus not working #400

Open stiivo opened 1 year ago

stiivo commented 1 year ago

API Platform version(s) affected: 3.0.8 Generator: 5.2.0

Description

Enum generation not working for schema.org/OrderStatus Instead OrderStatus becomes a normal Entity

How to reproduce

types:
  Thing:
    properties:
      gender: { range: "https://schema.org/GenderType" }
      orderStatus: { range: "https://schema.org/OrderStatus" }
  GenderType:
    properties:
      gender: [ ]
  OrderStatus:
    properties:
      orderStatus: [ ]

$ php vendor/bin/schema generate config/schema.yaml

alanpoulain commented 1 year ago

Probably because OrderStatus is not a direct subclass of Enumeration. The corresponding code is here, do you want to try to fix it? https://github.com/api-platform/schema-generator/blob/8b66b379ff1166c98824ff72237cbebd6c2c0256/src/Schema/Model/Class_.php#L69-L74

stiivo commented 1 year ago

Hi alan,

thanks for the very fast reply.

I m going to check if there are any other enumeration classes besides Enumeration and StatusEnumeration and submit a pull request when done.

thanks