- Fixed more template rendering issues.
- Updated dependencies.
- Updated Rust to v1.83 (for development).
- Fixed an issue where the YAML template rendered wouldn't nest fields correctly.
- Updated dependencies.
- Updated Rust to v1.82 (for development).
- Bubble up Pkl error when applicable.
- Added support for
#[serde(deny_unknown_fields)]
to struct and enum containers. - Added support for
#[serde(rename_all_fields)]
to enum containers. - Added support for
#[serde(untagged)]
to enum variants.
- Updated dependencies.
- More serde optimizations and fixes.
- Updated
Schema
,SchemaField
, andSchemaType
to implementSchematic
. Right now they just default to "unknown" shapes, but was added so that composition doesn't error.
- Updated dependencies.
- Fixed some issues around serializing the schemas.
- Refactored the internals of how merge/validation errors work.
- Removed
Config::META
andConfigError::META
. UseSchematic::schema_name()
instead. - Removed
url
as a default Cargo feature. - Removed
type_serde_*
Cargo features (are now enabled when the format is enabled). - Renamed
valid_*
Cargo features tovalidate_*
. - Renamed some error enum variants.
- Updated
SchemaRenderer::render
to receive an owned copy of the schemas. - Removed references from
SchemaRenderer::render
. Useschemas
keys instead. - Removed generics from
SchemaGenerator
andSchemaRenderer
.
// Before
fn render(
&mut self,
schemas: &'gen IndexMap<String, Schema>,
references: &'gen HashSet<String>,
) -> RenderResult;
// After
fn render(&mut self, schemas: IndexMap<String, Schema>) -> RenderResult;
- Added experimental support for the Pkl configuration language (
.pkl
files).- There are caveats to using Pkl, please refer to the docs.
- Added a
pkl
Cargo feature to enable the Pkl format. - Added a
env
Cargo feature for toggling environment variable functionality. Enabled by default. - Added a
extends
Cargo feature for config extending functionality. Enabled by default. - Added a
validate
Cargo feature for toggling validation functionality. Enabled by default. - Added a
schema_serde
Cargo feature for allowing theSchema
to be serialized. - Reworked how parser and validator errors are rendered in the terminal.
- Added an MSRV requirement for v1.71.1.
- Updated Rust to v1.80 (for development).
- We now track
#[deprecated]
on containers. - TypeScript
- When rendering a struct field that has an enum type, we'll include a
@type
doc tag for all variants. - Deprecated structs (interfaces) and enums will now contain
@deprecated
on the container.
- When rendering a struct field that has an enum type, we'll include a
- Updated
garde
(validation) to v0.20. - Updated dependencies.
- Updated
garde
(validation) to v0.19. - Updated dependencies.
- Updated settings with
#[setting(default)]
or#[serde(default)]
to be considered an "optional field" in the context of JSON schemas and TypeScript types.
- Fixed partial containers missing their comments.
- Brought back the concept of
SchemaField
, as it solved some edge cases related to structs.
- Fixed missing container comments.
- Added support for tuple based structs (newtypes).
In preparation for v1, we've made a bunch of breaking changes. For the most part this is transparent if using the macros, otherwise you'll need to update your schema implementations.
-
Rewrote the
Schematic
trait (and indirectly theConfig
andConfigEnum
traits) from the ground up. The new API uses a builder pattern to construct the schema. This allows for all types to support names, descriptions, references, and more metadata. It also helps to avoid circular references.// Before impl Schematic for T { fn generate_schema() -> schematic::SchemaType { // Create the schema type } } // After impl Schematic for T { fn schema_name() -> Option<String> { None // Required for non-primitives } fn build_schema(mut schema: schematic::SchemaBuilder) -> schematic::Schema { // Build the schema schema.build() } }
-
Updated renderers with lifetimes, so that data from the generator can be borrowed correctly. If you're using the built-in renderers, everything should continue to work correctly.
// Before impl SchemaRenderer<O> for T { fn render( &mut self, schemas: &IndexMap<String, Schema>, references: &HashSet<String>, ) -> RenderResult<O> { // } } // After impl<'gen> SchemaRenderer<'gen, O> for T<'gen> { fn render( &mut self, schemas: &'gen IndexMap<String, Schema>, references: &'gen HashSet<String>, ) -> RenderResult<O> { // } }
-
Updated renderer methods to receive the schema as an immutable referenced argument. The schemas contains the name, description, and more.
// Before impl SchemaRenderer<O> for T { fn render(&mut self, array: &ArrayType) -> RenderResult<O> { // } } // After impl<'gen> SchemaRenderer<'gen, O> for T<'gen> { fn render(&mut self, array: &ArrayType, schema: &Schema) -> RenderResult<O> { // } }
-
Updated default value functions (handlers) to return a
Result
. This now aligns with the other handler functions.// Before fn default_count(ctx: &Context) -> Option<usize> { Some(10) } // After fn default_count(ctx: &Context) -> Result<Option<usize>, HandlerError> { Ok(Some(10)) }
-
Updated all handler functions, excluding validators, to return a
HandlerError
. -
Removed
SchemaField
and merged its functionality intoSchema
.
- Added a
property_format
option to the TypeScript renderer. - Added a
tracing
feature flag, that will wrap generated config methods with#[tracing::instrument]
. - Updated the macros to support
Box
for#[setting(nested)]
struct fields. - Updated the macro generated code to use
Box
in many places to reduce the size of enums and structs. - Updated non-path based field types (tuples, arrays, etc) to support
Option
.
- Updated dependencies.
- Updated Rust to v1.78 (for development).
- Switched unit-only enums with a fallback to use "any of" instead of "one of", as the latter causes validation issues.
- Fixed unit-only enums with a fallback variant generating the wrong JSON schema and TypeScript types.
- Updated dependencies.
- reqwest v0.11 -> v0.12
- rustls v0.21 -> v0.22
- Updated Rust to v1.77.2 (for development).
- Added a basic
ParseError
that can be used when implementing custom parsing viaTryFrom
,FromStr
, serde, etc.
- Updated dependencies.
- Added a
markdown_descriptions
option to the JSON Schema renderer. This will include amarkdownDescription
field in the schema output, which can be used by VSCode and other tools. This is a non-standard feature.
- Fixed some issues around JSON Schema
title
generation.
- Added new JSON Schema renderer options:
allow_newlines_in_description
- Allows newlines in descriptions, otherwise strips them. Defaults tofalse
.mark_struct_fields_required
- Mark all non-option struct fields as required. Defaults totrue
for backwards compatibility.set_field_name_as_title
- Sets the field's name as thetitle
of each schema entry. Defaults tofalse
.
- Updated to Rust v1.76.
- Updated dependencies.
- Removed
type_version_spec
andtype_warpgate
features (use theschematic
feature on those crates instead). - Renamed renderer related features:
json_schema
->renderer_json_schema
template
->renderer_template
typescript
->renderer_typescript
- Added a 4th boolean argument to validator functions, which denotes whether its validating the final config, or a partial config. This arg can be used to differentiate between the 2, change logic, or avoid validating.
- Added 4 new validator functions:
min_bytes
andmax_bytes
min_chars
andmax_chars
- Updated
garde
(validation) to v0.18. - Updated
miette
to v7.
- Added
#[setting(alias)]
support (which maps to serde).
- Updated dependencies.
- Added
type_indexmap
feature, that implements schematic types forindexmap
values.
- Added
#[setting(required)]
support forOption
al settings.
- Updated
garde
(validation) to v0.17. - Updated
version_spec
to v0.2. - Updated
warpgate
to v0.9.
- Added
JsonTemplateRenderer
,JsoncTemplateRenderer
,TomlTemplateRenderer
, andYamlTemplateRenderer
for distinctness. - Added
TemplateOptions.expand_fields
for expanding arrays and objects with an example item.
- Fixed nested configs receiving an environment variable when
env_prefix
is set. - Fixed an issue where comments with bold markdown syntax was being rendered incorrectly.
- Fixed trailing commas for JSON template format.
- Fixed a build failure when all features are disabled.
- Fixed an issue where environment variables for
SchemaField
weren't being populated fromenv_prefix
.
- Refactored schema APIs for better usability.
- Updated
TypeScriptOptions.exclude_references
andexternal_types
to aVec
instead ofHashSet
. - Updated
EnumType.variants
toVec<LiteralValue>
instead ofVec<LiteralType>
. - Updated
ObjectType.required
andStructType.required
to be wrapped inOption
. - Updated
SchemaField.deprecated
toOption<String>
instead ofbool
. - Updated
SchemaField.name
toString
instead ofOption<String>
.
- Updated
- Added official documentation: https://moonrepo.github.io/schematic
- Added a new file template generator.
- Added constructor methods for schema types.
- Added
SchemaType::enumerable
method. - Added
SchemaField.env_var
field. - Added
EnumType.default_index
andUnionType.default_index
fields. - Updated
typescript
comment output to include@deprecated
and@envvar
. - Reduced the amount of code that macros generate for the
Schematic
implementation.
- Updated to Rust v1.75.
- Updated dependencies.
- Updated help text to also apply for parser errors.
- Added
ConfigLoader.set_help
to customize help text for validation errors.
- Added serde
skip_serializing
andskip_deserializing
support.
- Added serde
flatten
support. - Added
type_serde_json
,type_serde_toml
, andtype_serde_yaml
features, that implements schematic types for serde values.
- Updated json schema unknown/any type to be a union of all types, instead of null.
- Updated dependencies.
- Updated dependencies.
- Fixed comments not rendering for enums/structs when generating TypeScript declarations.
- Updated
garde
(validation) to v0.16. - Updated dependencies.
- Fixed
rename
on containers not being respected on generated output.
- Fixed "lowercase" and "UPPERCASE" formats incorrectly applying casing.
- Fixed a missing module error based on feature changes.
- Updated enums with all unit variants to use the
Enum
schema type, instead of theUnion
schema type. Enums that mix and match unit with other variants will to continue to useUnion
, and will respect serde tagging.
- Reworked dependencies and features so that some dependencies only enable when a feature is enabled.
- Added an
exclude
attribute for#[setting]
and#[schema]
that excludes the field from the generated schema.- For
Schematic
, excludes from the schema. - For
Config
, excludes from the schema, but is still required for the partial config.
- For
- Added
type_rust_decimal
feature, that implements schematic types for therust_decimal
crate. - Added a simple caching layer for caching URL requests.
- Added
Cacher
trait. - Added
Loader::set_cacher()
method.
- Added
- Removed
json
as a default feature. You must now enable the file formats you want.
- Added a
Schematic
derive macro that only implements theschematic::Schematic
trait. - Added a
config
feature that enables configuration functionality. Can usedefault-features = false
to only use schema functionality.
- Updated Rust to v1.73.
- Added support for
f32
andf64
types. - Added
type_version_spec
feature, that implements schematic types for theversion_spec
crate.
- Removed
Eq
from partial types so that complex types can be used.
- Moved
reqwest
usage behind a feature namedurl
. This is enabled by default.
- Fixed an error where Rust would fail to compile if no features are enabled.
- Updated Rust to v1.72.
- Updated
garde
(validation) to v0.15. - Updated
reqwest
to userustls-tls-native-roots
instead ofrustls-tls
. - Updated dependencies.
- Added
type_warpgate
feature, that implements schematic types for thewarpgate
crate.
- Fixes a bad release.
- Added
type_semver
feature, that implements schematic types for thesemver
crate. - Added basic
#[config]
support forConfigEnum
.- Supports
rename
andrename_all
(matches serde). - Added
before_parse
which transforms the string value before parsing (From
,FromStr
, etc). Supports "lowercase" and "UPPERCASE".
- Supports
- Fixed serde
rename
not working onConfigEnum
.
- Added
type_relative_path
feature, that implements schematic types for therelative-path
crate. - Added
type_url
feature, that implements schematic types for theurl
crate.
- Updated Rust to v1.71.
- Updated
garde
(validation) to v0.14. - Updated dependencies.
- Added support for
#[derive(Config)]
on enums with unit/tuple variants (struct variants not supported).- This allows for nested partials and configs to be properly handled.
- Derived enums also automatically generate accurate schemas.
- Added support for
#[config(serde(...))]
attribute (doesn't support everything, mainly enum tagging). - Added support for
#[setting(validate)]
on nested fields (was previously an error). - Updated primitive schema types to include the default value.
- Renderers will now include the default when applicable.
- Fixed a handful of issues with schema generation and partial detection.
- Fixed an issue where multiline comments weren't parsed correctly.
- Fixed an issue with string formatting that would incorrectly handle digit characters.
- Fixed a missing title/description for union types.
- Added back
Eq
andPartialEq
to partial configs.
- Renamed
SettingPath
toPath
. - Renamed
Segment
toPathSegment
. - Updated
PartialConfig.default_values
andenv_values
to returnResult<Option<Self>>
instead ofResult<Self>
.
- Added
Deserialize
toFormat
,Layer
, andSource
. - Improved file system and HTTP error handling.
- Improved and cleaned up tracing logs.
- Generator
- Updated JSON schema arrays to use
contains
when applicable.
- Updated JSON schema arrays to use
- Schema
- Added support for
chrono
types (behind thetype_chrono
feature). - Added support for
regex
types (behind thetype_regex
feature).
- Added support for
- Generator
- Updated literal types in JSON schemas to use
const
.
- Updated literal types in JSON schemas to use
- Generator
- Added description to struct types.
- Updated structs to render
additionalProperties: false
for JSON schemas.
- Generator
- Fixed string/number/float enum values not rendering for TypeScript types.
- Schema
- Changed nullable schemas from "one of" to "any of" union types.
- Fixed deeply nested partial values not being marked nullable.
- Generator
- Updated struct fields to be sorted alphabetically.
- Added
disable_references
,exclude_references
,external_types
, andindent_char
options to TypeScript.
- Generator
- Fixed an issue where nested enums/unions would sometimes not use references.
- Fixed an issue with TypeScript arrays and unions. Will now wrap in parens.
- Fixed TypeScript enum/union rendering discrepancies.
- Allow the schema name to be customized after creation.
- Fixed
HashMap
andHashSet
schematic implementations.
- Removed
T::META.fields
(usegenerate_schema()
instead). - Moved the TypeScript renderer to
schematic::renderers::typescript::TypeScriptRenderer
.- Removed
schematic::typescript::TypeScriptGenerator
.
- Removed
- Added a new schema layer that defines the structure of built-in Rust types and schematic
configuration types.
- Implements the new
Schematic
trait. - Types provided by the new
schematic_types
crate. - Hidden behind the
schema
feature flag (very experimental).
- Implements the new
- Added
schematic::schema::SchemaGenerator
for generating outputs from schemas.- Uses renderers for generating the appropriate output.
- Moves TypeScript to a renderer.
- Added JSON schema generation.
- Behind a new
json_schema
feature.
- Behind a new
- Added
TypeScriptGenerator::add_custom
for mapping custom types.
- Renamed
ConfigMeta
trait toMeta
.
- Added
ConfigEnum
trait that theConfigEnum
derive macro implements.- Trait contains
META
. - Trait provides a
variants()
method.
- Trait contains
- Added
fields
toMeta
trait.- Updated
Config
trait to implement fields.
- Updated
- Added TypeScript type generation (experimental, will probably change).
- Behind a new
typescript
feature. - Code can be generated with the
schematic::typescript::TypeScriptGenerator
.
- Behind a new
- Updated partials to inherit
#[allow]
,#[warn]
, and#[deprecated]
attributes.
- Refactored
derive_enum
maro (should be backwards compatible).