Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Dependabot configuration file
#

version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
ignore:
# Both schemars08 and schemars1 rename the schemars package; block
# major-version bumps so each stays on its line, while minor and
# patch updates flow to both.
- dependency-name: "schemars"
update-types: ["version-update:semver-major"]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
45 changes: 43 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,74 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Report cargo version
run: cargo --version
- name: Report rustfmt version
run: cargo fmt -- --version
- name: Check style
run: cargo fmt -- --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Report clippy version
run: cargo clippy --version
- name: Run clippy
run: cargo clippy --locked --all-targets --all-features -- -D warnings

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Build documentation
run: cargo doc --locked --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings

build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
# 1.97 is the MSRV
rust-version: [ stable, "1.97" ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
with:
toolchain: ${{ matrix.rust-version }}
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Report rustc version
run: rustc --version
- name: Build
run: cargo build --locked --tests --verbose
- name: Run tests (no features)
run: cargo test --locked --verbose
# The feature legs exercise platform-independent code; run them on
# ubuntu only and keep windows/macos to the default-feature leg.
- name: Run tests (schemars 0.8)
if: matrix.os == 'ubuntu-latest'
run: cargo test --locked --features schemars08 --verbose
- name: Run tests (schemars 1.x)
if: matrix.os == 'ubuntu-latest'
run: cargo test --locked --features schemars1 --verbose
- name: Run tests (all features)
if: matrix.os == 'ubuntu-latest'
run: cargo test --locked --all-features --verbose
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ edition = "2024"
rust-version = "1.97"
license = "Apache-2.0"
repository = "https://github.com/oxidecomputer/json-serde"
description = "Serde helpers for JSON-specific serialization semantics"
description = "Runtime serde helpers for esoteric JSON semantics"
keywords = ["serde", "json", "json-schema", "codegen"]
categories = ["encoding"]
exclude = [".github", "rust-toolchain.toml"]

[package.metadata.docs.rs]
all-features = true
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# json-serde

[![json-serde on crates.io](https://img.shields.io/crates/v/json-serde)](https://crates.io/crates/json-serde)
[![Documentation (latest release)](https://img.shields.io/badge/docs-latest%20version-brightgreen.svg)](https://docs.rs/json-serde)
[![License](https://img.shields.io/badge/license-Apache-green.svg)](https://github.com/oxidecomputer/json-serde/blob/main/LICENSE)

Runtime serde helpers for esoteric JSON semantics

## Overview
Expand Down Expand Up @@ -62,11 +66,13 @@ specific, named properties may be disallowed. To handle these cases, the
With the `schemars1` or `schemars08` feature enabled, its `JsonSchema` impl
emits the `false`--unsatisfiable--schema.

Note that schemars 0.8 (through 0.8.22) incorrectly marks `default` +
`skip_serializing` fields as required; on types deriving the schemars 0.8
`JsonSchema`, use `#[serde(skip_serializing_if = "::json_serde::always")]`
instead of `skip_serializing`. The `always` predicate serializes
identically and works around the schemars bug.
On types deriving `JsonSchema` (either version), use
`#[serde(skip_serializing_if = "::json_serde::always")]` instead of
`skip_serializing`. The `always` predicate serializes identically and produces
better schemas: schemars 0.8 (through 0.8.22) incorrectly marks `default` +
`skip_serializing` fields as required, and schemars 1.0 (as of 1.2.2)
spuriously annotates the field `writeOnly` (when, in fact, no value can be
written!).

## Features

Expand All @@ -79,5 +85,5 @@ derive-less for consumers.

## Notes

- Pre-publication; API unstable.
- Early alpha; API unstable.
- Part of the typify/progenitor code-generation stack.
Loading
Loading