- Fixed an incorrect double nested object for flattened fields.
- Added
#[serde(flatten)]support to schema generation.- Added
SchemaField.flattenfield. - Updated
JsonSchemaRendererto render flattened fields asadditionalProperties. - Updated
TypeScriptRendererto render flattened fields as index signatures & intersection types. - Updated
TemplateRenderers to skip rendering flattened fields.
- Added
- Updated
#[serde(untagged)]enums to render better error messages based on the variant types.
- Updated
reqwestto v0.13. - Updated
rpklto v0.7. - Updated dependencies.
- Updated enums/unions in templates to render the first item by default, instead of null.
This release changes how formats work. Instead of using the Format enum, formats now implement the
SourceFormat trait. This allows for custom formats to be created and used with the ConfigLoader.
- Updated
ConfigLoader::new()to auto-register formats based on enabled features. UseConfigLoader::default()to create a loader without formats. - Updated
ConfigLoader#code()to require a file name/path as the 2nd argument, instead of theFormatenum. The file extension will be used to determine the format. - Reworked the
Sourceenum heavily. - Renamed the
extract_extfunction toextract_file_ext, and updated it to not include the leading.. - Replaced
serde_yamlwithserde_norwayfor YAML parsing. This is due toserde_yamlbeing unmaintained. - Removed the
Formatenum. - Removed the
ymlfeature, useyamlinstead. - Removed the
is_source_formatfunction.
- Added
.jsoncsupport. - Added a
SourceFormattrait, with built-in formats available atschematic::config::formats. - Added a
ConfigLoader#add_format()method. - Added a
extract_file_namefunction. - Added
TemplateOptions.custom_valuesfor specifying custom values for specific fields in a template. - Added
TemplateOptions.only_fieldsto only render specific fields in a template. - Added options to
PklFormat, allowing custom readers to be defined.
- Updated to Rust v1.91.
- Updated
rpklto v0.6. - Updated
ronto v0.12. - Updated dependencies.
- Added
@valuestag to YAML renderer showing all possible enum values.
- Fixed an issue where source URLs that contain a query string would not be parsed.
- Fixed a description issue when building the schema.
- Fixed
extendsvalidation not supporting query strings in the a URL.
- Added
SchemaField.aliasesproperty. - Added aliases support to JSONSchema and TypeScript renderers.
- Added an
exclude_aliasesoption to disable inclusion.
- Added an
- Added a
VersionSettingtype that wrapssemver::Versionand implements additional traits so that it can be used in configs.- Requires the
type_semverfeature. - Default implementation uses
0.0.0.
- Requires the
- Updated dependencies.
- Added a
RegexSettingtype that wrapsregex::Regexand implements additional traits so that it can be used in configs.- Requires the
type_regexfeature. - Default implementation uses
.(match all) pattern.
- Requires the
- Updated to Rust v1.88.
- Updated dependencies.
- Added RON support (
.ronfiles) behind theronfeature. - Added
type_uuidfeature for UUID schema support.
- Added
#[config(partial())]to containers, allow derives to be set and applied to the generated partial configs.
- Fixed an issue where nested optional configs (
setting: Option<Config>) would not be marked as some when an applicable environment variable is set.
- Added
Displayto all schema types, so that TypeScript-like type strings can be generated.
- Updated dependencies.
- Updated dependencies.
- Updated dependencies.
- Support parsing files with a byte-order mark (BOM).
- Updated to Rust v1.86.
- Updated dependencies.
- Added
#[setting(transform)], which allows defined values to be transformed before being finalized. - Added support for
#[setting(default)]toOptional settings.
- Updated dependencies.
- Updated to Rust v1.85 and 2024 edition.
- Fixed an issue where importing
Resultwould break our generated macro code.
- Updated dependencies.
- When using the
pklformat, we now check for thepklbinary, and error if not found.
- Added
ymlandserde_ymlfeatures, which usesserde_ymlfor parsing instead ofserde_yaml, as the latter has been deprecated for sometime.
- Updated
garde(validation) to v0.22. - Updated dependencies.
- Added
ConfigSetting.nestedto recursively include nested settings.
- Added
Config::settings(), which returns basic metadata about settings on the config.
- Fixed an issue where TypeScript imports weren't sorted and the order would randomize.
- Updated
garde(validation) to v0.21. - Updated dependencies.
- 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, andSchemaTypeto 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::METAandConfigError::META. UseSchematic::schema_name()instead. - Removed
urlas 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::renderto receive an owned copy of the schemas. - Removed references from
SchemaRenderer::render. Useschemaskeys instead. - Removed generics from
SchemaGeneratorandSchemaRenderer.
// 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 (
.pklfiles).- There are caveats to using Pkl, please refer to the docs.
- Added a
pklCargo feature to enable the Pkl format. - Added a
envCargo feature for toggling environment variable functionality. Enabled by default. - Added a
extendsCargo feature for config extending functionality. Enabled by default. - Added a
validateCargo feature for toggling validation functionality. Enabled by default. - Added a
schema_serdeCargo feature for allowing theSchemato 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
@typedoc tag for all variants. - Deprecated structs (interfaces) and enums will now contain
@deprecatedon 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
Schematictrait (and indirectly theConfigandConfigEnumtraits) 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
SchemaFieldand merged its functionality intoSchema.
- Added a
property_formatoption to the TypeScript renderer. - Added a
tracingfeature flag, that will wrap generated config methods with#[tracing::instrument]. - Updated the macros to support
Boxfor#[setting(nested)]struct fields. - Updated the macro generated code to use
Boxin 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
ParseErrorthat can be used when implementing custom parsing viaTryFrom,FromStr, serde, etc.
- Updated dependencies.
- Added a
markdown_descriptionsoption to the JSON Schema renderer. This will include amarkdownDescriptionfield 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
titlegeneration.
- 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 totruefor backwards compatibility.set_field_name_as_title- Sets the field's name as thetitleof each schema entry. Defaults tofalse.
- Updated to Rust v1.76.
- Updated dependencies.
- Removed
type_version_specandtype_warpgatefeatures (use theschematicfeature on those crates instead). - Renamed renderer related features:
json_schema->renderer_json_schematemplate->renderer_templatetypescript->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_bytesandmax_bytesmin_charsandmax_chars
- Updated
garde(validation) to v0.18. - Updated
mietteto v7.
- Added
#[setting(alias)]support (which maps to serde).
- Updated dependencies.
- Added
type_indexmapfeature, that implements schematic types forindexmapvalues.
- Added
#[setting(required)]support forOptional settings.
- Updated
garde(validation) to v0.17. - Updated
version_specto v0.2. - Updated
warpgateto v0.9.
- Added
JsonTemplateRenderer,JsoncTemplateRenderer,TomlTemplateRenderer, andYamlTemplateRendererfor distinctness. - Added
TemplateOptions.expand_fieldsfor expanding arrays and objects with an example item.
- Fixed nested configs receiving an environment variable when
env_prefixis 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
SchemaFieldweren't being populated fromenv_prefix.
- Refactored schema APIs for better usability.
- Updated
TypeScriptOptions.exclude_referencesandexternal_typesto aVecinstead ofHashSet. - Updated
EnumType.variantstoVec<LiteralValue>instead ofVec<LiteralType>. - Updated
ObjectType.requiredandStructType.requiredto be wrapped inOption. - Updated
SchemaField.deprecatedtoOption<String>instead ofbool. - Updated
SchemaField.nametoStringinstead 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::enumerablemethod. - Added
SchemaField.env_varfield. - Added
EnumType.default_indexandUnionType.default_indexfields. - Updated
typescriptcomment output to include@deprecatedand@envvar. - Reduced the amount of code that macros generate for the
Schematicimplementation.
- Updated to Rust v1.75.
- Updated dependencies.
- Updated help text to also apply for parser errors.
- Added
ConfigLoader.set_helpto customize help text for validation errors.
- Added serde
skip_serializingandskip_deserializingsupport.
- Added serde
flattensupport. - Added
type_serde_json,type_serde_toml, andtype_serde_yamlfeatures, 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
renameon 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
Enumschema type, instead of theUnionschema 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
excludeattribute 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_decimalfeature, that implements schematic types for therust_decimalcrate. - Added a simple caching layer for caching URL requests.
- Added
Cachertrait. - Added
Loader::set_cacher()method.
- Added
- Removed
jsonas a default feature. You must now enable the file formats you want.
- Added a
Schematicderive macro that only implements theschematic::Schematictrait. - Added a
configfeature that enables configuration functionality. Can usedefault-features = falseto only use schema functionality.
- Updated Rust to v1.73.
- Added support for
f32andf64types. - Added
type_version_specfeature, that implements schematic types for theversion_speccrate.
- Removed
Eqfrom partial types so that complex types can be used.
- Moved
reqwestusage 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
reqwestto userustls-tls-native-rootsinstead ofrustls-tls. - Updated dependencies.
- Added
type_warpgatefeature, that implements schematic types for thewarpgatecrate.
- Fixes a bad release.
- Added
type_semverfeature, that implements schematic types for thesemvercrate. - Added basic
#[config]support forConfigEnum.- Supports
renameandrename_all(matches serde). - Added
before_parsewhich transforms the string value before parsing (From,FromStr, etc). Supports "lowercase" and "UPPERCASE".
- Supports
- Fixed serde
renamenot working onConfigEnum.
- Added
type_relative_pathfeature, that implements schematic types for therelative-pathcrate. - Added
type_urlfeature, that implements schematic types for theurlcrate.
- 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
EqandPartialEqto partial configs.
- Renamed
SettingPathtoPath. - Renamed
SegmenttoPathSegment. - Updated
PartialConfig.default_valuesandenv_valuesto returnResult<Option<Self>>instead ofResult<Self>.
- Added
DeserializetoFormat,Layer, andSource. - Improved file system and HTTP error handling.
- Improved and cleaned up tracing logs.
- Generator
- Updated JSON schema arrays to use
containswhen applicable.
- Updated JSON schema arrays to use
- Schema
- Added support for
chronotypes (behind thetype_chronofeature). - Added support for
regextypes (behind thetype_regexfeature).
- 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: falsefor 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_charoptions 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
HashMapandHashSetschematic 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
Schematictrait. - Types provided by the new
schematic_typescrate. - Hidden behind the
schemafeature flag (very experimental).
- Implements the new
- Added
schematic::schema::SchemaGeneratorfor generating outputs from schemas.- Uses renderers for generating the appropriate output.
- Moves TypeScript to a renderer.
- Added JSON schema generation.
- Behind a new
json_schemafeature.
- Behind a new
- Added
TypeScriptGenerator::add_customfor mapping custom types.
- Renamed
ConfigMetatrait toMeta.
- Added
ConfigEnumtrait that theConfigEnumderive macro implements.- Trait contains
META. - Trait provides a
variants()method.
- Trait contains
- Added
fieldstoMetatrait.- Updated
Configtrait to implement fields.
- Updated
- Added TypeScript type generation (experimental, will probably change).
- Behind a new
typescriptfeature. - Code can be generated with the
schematic::typescript::TypeScriptGenerator.
- Behind a new
- Updated partials to inherit
#[allow],#[warn], and#[deprecated]attributes.
- Refactored
derive_enummaro (should be backwards compatible).