fix: unwrap data in document_types.get(), rename schema_ → jsonSchema, add is_public#20
Merged
Merged
Conversation
…jsonSchema, add is_public Closes #19 - document_types.get() (sync + async + raw response wrappers) now unwraps the { data } envelope returned by GET /api/document-types/{id}. Previously every typed field silently fell back to defaults because the fields were nested under data. - Renamed DocumentType.schema_ to DocumentType.jsonSchema to match the API wire format. Type-only breaking change (pre-1.0 patch). - Added is_public kwarg to create() and update() (sync + async + raw response wrappers) closing a gap from the docutray-node#18 port. - Updated docstring example, README example, and tests. Bumped to 0.2.1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19
Summary
Ports docutray-node#20 to the Python SDK and closes a small gap from the docutray-node#18 port (missing
is_publickwarg).Bug fix —
document_types.get()returns the raw{data}wrapperGET /api/document-types/{id}returns{ "data": {...} }, same asPOST/PUT. Withmodel_config = ConfigDict(extra="allow")onDocumentType,model_validate({"data": {...}})did not raise — but every typed field (id,name,codeType, …) silently fell back to defaults because the actual fields were nested underdata. Consumers received aDocumentTypewhose fields all looked empty.Fixed sync (
document_types.py:127), async (document_types.py:402), and the raw response wrappers (_response.py:803, 1023) by mirroring the unwrap pattern already used bycreate()/update():Type-only breaking change —
DocumentType.schema_→DocumentType.jsonSchemaThe API returns this field as
jsonSchema(consistent withcodeType,isDraft,createdAt). The previous nameschema_never matched the wire — the field was alwaysNone. Renamed to match the API. Pre-1.0 patch releases are allowed to carry type-level breaking changes per project policy. Updated the docstring example inresources/document_types.py:124and the README example.Gap closed —
is_publickwarg on create/updateThe Node
DocumentTypeCreateParams/DocumentTypeUpdateParamsinterfaces both exposeisPublic. Addedis_public: bool | None = Nonekwarg to all six methods (sync, async, and raw response wrappers for bothcreate()andupdate()).Acceptance criteria
client.document_types.get(id)returns a flatDocumentTypewith all fields populated (sync + async + raw wrappers).DocumentType.jsonSchemareplacesDocumentType.schema_. Docstring + README example updated.client.document_types.create(...)and.update(...)acceptis_public: bool | None = None(six methods total).get()mocked with{"data": {...}}and assert unwrapped result includingjsonSchema. Tests coveris_public=True/is_public=Falseforwarding to body asisPublic, andis_public=Noneomits the field.uv run pytest(340 passed),uv run mypy src(clean),uv run ruff check src tests(clean).[0.2.1]entry; version bumped inpyproject.tomlandsrc/docutray/_version.py.Out of scope
The Node PR #20 description flags an audit of other endpoints that may also be missing the
{data}unwrap. In Python,KnowledgeBases.getandKnowledgeBaseDocuments.getalready unwrap correctly. Status-polling endpoints (Steps.get_status,Convert.*,Identify.*) most likely are NOT wrapped, but should be confirmed in a separate issue.Test plan
tests/test_resources/test_document_types.py—get()mocks{"data": {...}}, assertsdoc_type.jsonSchemapopulated; new tests foris_publicforwarding (sync create + update; existing async tests still pass against unchanged surface).client.document_types.get()no longer returns empty fields.🤖 Generated with Claude Code