nsj-rest-lib is a Python library for building declarative REST APIs, adhering to internal guidelines and focusing on DTO (Data Transfer Object) and Entity patterns. It simplifies API creation by abstracting common patterns for data mapping, validation, and persistence. The current version is 6.4.1, and it maintains an active release cadence with regular feature additions and bug fixes.
pip install nsj-rest-libVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define an Entity (mapping to a database table) and various DTOs (Data Transfer Objects) for API representation, including using `DTOAggregator` for nested structures that map to a single underlying entity. This setup forms the core declarative definition for building REST APIs with nsj-rest-lib.
Review your update operations and DTO definitions. Ensure all fields you intend to update are present in the `DTO`. If a field is not in the DTO, it will no longer be implicitly updated or set to `NULL` by the library.
When using `DTOAggregator`, ensure your database schema and entity mapping reflect that the nested DTO's properties are columns within the same primary entity table, not a separate joined entity. Plan your `Entity` definitions accordingly.
To ensure the complete (summary) object is echoed back after an `INSERT`, set the `retrieve_after_insert=True` flag in your route or service configuration for POST requests.
If you encounter errors about a field being read-only, either remove `read_only=True` from the `DTOField` definition if it should be writable, or ensure your API clients do not send data for that specific field during write operations.
Verify that all fields intended for update are explicitly defined in the DTO used for the update operation. Ensure DTOs are kept up-to-date with entity definitions, reflecting the v4.0.0 breaking change.
Ensure `retrieve_after_insert=True` is set on your route or service configuration for POST requests if your client expects the full object (with its ID and other properties) to be returned after an insert (available in v3.0.0+).
Either remove the `read_only=True` flag from the `DTOField` definition if the field should be modifiable, or ensure that your API requests for `POST`, `PUT`, or `PATCH` do not include data for this specific field.
Always create a new class that inherits from `EntityBase` or `DTOBase` and define its fields. For example, `class MyConcreteEntity(EntityBase): ...` or `class MyConcreteDTO(DTOBase): ...`.
No dependency data recorded yet.