Bug 41520: Filter out record_table from AdditionalFieldValue API responses
Bug 35451 added a record_table field to the additional_field_values
database table for performance optimization (better joins). However,
this field was not added to the OpenAPI schema, and with
additionalProperties: false, the API validator rejects responses
containing it.
Rather than adding this internal implementation detail to the public
API schema, this patch adds a custom to_api method to
Koha::AdditionalFieldValue that filters out the record_table field.
This approach:
1. Keeps the database optimization from Bug 35451
2. Prevents internal implementation details from cluttering the API
3. Maintains context that API consumers already have from parent objects
4. Fixes OpenAPI validation errors for ERM agreements, licenses, and
packages using extended_attributes
Test plan:
1. Create an ERM agreement with additional fields/extended attributes
2. Access the agreement via the API with extended_attributes embedded
3. Verify the response includes extended_attributes but not record_table
4. Confirm no OpenAPI validation warnings in plack-api-error.log
5. prove t/db_dependent/api/v1/erm_agreements.t
6. Verify all tests pass
Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 60d84f91e6)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
This commit is contained in:
parent
04693febd7
commit
c29ded1b34
|
|
@ -28,6 +28,23 @@ sub field {
|
|||
return Koha::AdditionalField->_new_from_dbic( $self->_result()->field() );
|
||||
}
|
||||
|
||||
=head3 to_api
|
||||
|
||||
Overloaded to_api method to exclude internal fields from API representation
|
||||
|
||||
=cut
|
||||
|
||||
sub to_api {
|
||||
my ( $self, $params ) = @_;
|
||||
|
||||
my $json = $self->SUPER::to_api($params);
|
||||
|
||||
# Remove internal database optimization fields that shouldn't be exposed via API
|
||||
delete $json->{record_table};
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
||||
=head3 _type
|
||||
|
|
|
|||
Loading…
Reference in New Issue