flat3 / lodata

The OData v4.01 Producer for Laravel
https://lodata.io/
MIT License
80 stars 27 forks source link

Update behaviour for `immutable` and `computed` properties #837

Closed yvo-niedrich closed 1 month ago

yvo-niedrich commented 4 months ago

OpenAPI Documentation

Property Filtering

Annotations

Changes

Bugfixes

yvo-niedrich commented 3 months ago

Found the docker command to boot up mongo - all test snapshots are updated now: Generated properties are listed in the OpenAPI documentation when describing an Entity.

Ready for merge (in my opinion)

27pchrisl commented 3 months ago

Hi @yvo-niedrich, thanks for the work! On the computed default properties I'm not sure it's correct to indicate those can be provided during a create operation, as they are still computed by the server and not the client?

27pchrisl commented 3 months ago

Ah, no you're right, "A value for this property can be provided by the client on insert and update. If no value is provided on insert, a non-static default value is generated"

27pchrisl commented 3 months ago

and in that case, the entity set drivers right now are incorrectly annotating with Computed, not ComputedDefaultValue - would you mind making that change as part of this?

yvo-niedrich commented 3 months ago

Ah, I believe I see what you mean. This one for example - right?

I'll go ahead and completely separate Computed from ComputedDefault in the types then... Will do tomorrow.

27pchrisl commented 3 months ago

In https://github.com/flat3/lodata/blob/be527e5a941fb4f9640778446002981823daed19/src/Drivers/EloquentEntitySet.php#L680 and https://github.com/flat3/lodata/blob/be527e5a941fb4f9640778446002981823daed19/src/Drivers/CSVEntityType.php#L21 for example, the standard drivers should be using Computed here.

yvo-niedrich commented 3 months ago

Had some time to spare and updated the PR already 🙈

I've also included another change (again thanks to @sean-james-eco) to properly validate UUIDs. Now a 400 error is returned - instead of the DatabaseException (HTTP 500) when the Eloquent Driver tries to write an invalid value to the database.

yvo-niedrich commented 1 month ago

Hey @27pchrisl are we still missing some of the updates you mentioned? I thought I caught them all 🤔

27pchrisl commented 1 month ago

@yvo-niedrich Nope! I just hadn't got round to reading all the changes : ) I'll tag shortly...