marshmallow-jsonschema translates marshmallow schemas into JSON Schema Draft v7 compliant jsonschema. It enables developers to generate JSON Schemas directly from their existing Marshmallow schemas, which is particularly useful for frontend form generation, API documentation, or validation in other systems. The current version is 0.13.0, released in October 2021, suggesting a maintenance rather than a rapid release cadence.
pip install marshmallow-jsonschemaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a basic Marshmallow schema and then use `marshmallow-jsonschema` to convert it into a JSON Schema representation. The output is a standard JSON Schema dictionary, ready for use in other applications.
Avoid using `marshmallow.fields.Enum` or consider using the `marshmallow-jsonschema-3` fork which addresses this and other OpenAPI/JSON Schema 3.x features. Alternatively, implement custom field handling for enums.
These are warnings from Marshmallow itself, not `marshmallow-jsonschema`. While the library might still function, upgrading `marshmallow-jsonschema` to a version that properly supports Marshmallow 4.x is the long-term solution. For now, ensure your Marshmallow schemas follow the latest best practices for field definition.
If you need to generate Marshmallow schemas from JSON Schema, you will need to use a different tool or implement a custom solution. This library is strictly a one-way conversion tool.
Avoid using `marshmallow.fields.Enum` directly. Instead, implement a custom field with a `_jsonschema_type_mapping` method, or consider using the `marshmallow-jsonschema-3` fork which provides updated compatibility.
While marshmallow-jsonschema 0.13.0 might still function, the long-term solution is to use a `marshmallow-jsonschema` version that officially supports Marshmallow 4.x (if one becomes available). Alternatively, pin your `marshmallow` dependency to a version less than 4.0.
Pin your `jsonschema` dependency to a version less than 4.0 by running `pip install 'jsonschema<4.0'`.
Install the library using pip: `pip install marshmallow-jsonschema`. Ensure you are installing it into the correct Python environment.