FriendsOfCake / crud-json-api

Build advanced JSON API Servers with almost no code.
https://crud-json-api.readthedocs.io/
MIT License
56 stars 32 forks source link

"'type' is a reserved keyword and cannot be used as attribute name in type "controller" #91

Closed dkruchok closed 6 years ago

dkruchok commented 6 years ago

I experience such an error because I have column "type" in my table and I don't want to rename it. How I can avoid this?

Maybe I can change the name of the property with the entity, but how I can do it only for API request? Or maybe it's possible to change with DynamicEntitySchema::getAttributes() then rename type property. Also how I can do it for a plugin?

Tried to create Shema file in plugin/src/Schema/JsonApi/EventsTicketSchema.php But looks like it doesn't see it.

namespace plugin\Schema\JsonApi; plugin.EventsTickets - table EventsTicket - entity

"errors": [
    {
        "code": "500",
        "title": "Internal Server Error",
        "detail": "'type' is a reserved keyword and cannot be used as attribute name in type 'events-tickets'"
    }
],
bravo-kernel commented 6 years ago

Like the error message clearly states... you cannot use type as it is a keyword reserved by JSON:API.

You can find more background information here. https://jsonapi.org/format/#document-resource-objects