diff --git a/head/schema-cplusplus/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.hpp b/head/schema-cplusplus/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.hpp
new file mode 100644
index 0000000..4e311aa
--- /dev/null
+++ b/head/schema-cplusplus/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.hpp
@@ -0,0 +1,176 @@
+//  To parse this JSON data, first install
+//
+//      json.hpp  https://github.com/nlohmann/json
+//
+//  Then include this file, and then do
+//
+//     TopLevel data = nlohmann::json::parse(jsonString);
+
+#pragma once
+
+#include "json.hpp"
+
+#include <optional>
+#include <stdexcept>
+#include <regex>
+
+namespace quicktype {
+    using nlohmann::json;
+
+    #ifndef NLOHMANN_UNTYPED_quicktype_HELPER
+    #define NLOHMANN_UNTYPED_quicktype_HELPER
+    inline json get_untyped(const json & j, const char * property) {
+        if (j.find(property) != j.end()) {
+            return j.at(property).get<json>();
+        }
+        return json();
+    }
+
+    inline json get_untyped(const json & j, std::string property) {
+        return get_untyped(j, property.data());
+    }
+    #endif
+
+    enum class FooState : int { XX, YY };
+
+    class StateInfoXxx {
+        public:
+        StateInfoXxx() = default;
+        virtual ~StateInfoXxx() = default;
+
+        private:
+        double change_time;
+        FooState state;
+
+        public:
+        const double & get_change_time() const { return change_time; }
+        double & get_mutable_change_time() { return change_time; }
+        void set_change_time(const double & value) { this->change_time = value; }
+
+        const FooState & get_state() const { return state; }
+        FooState & get_mutable_state() { return state; }
+        void set_state(const FooState & value) { this->state = value; }
+    };
+
+    enum class WooState : int { ASD, QWE, ZXC, TYU };
+
+    class StateInfoWww {
+        public:
+        StateInfoWww() = default;
+        virtual ~StateInfoWww() = default;
+
+        private:
+        double change_time;
+        WooState state;
+
+        public:
+        const double & get_change_time() const { return change_time; }
+        double & get_mutable_change_time() { return change_time; }
+        void set_change_time(const double & value) { this->change_time = value; }
+
+        const WooState & get_state() const { return state; }
+        WooState & get_mutable_state() { return state; }
+        void set_state(const WooState & value) { this->state = value; }
+    };
+
+    class TopLevel {
+        public:
+        TopLevel() = default;
+        virtual ~TopLevel() = default;
+
+        private:
+        StateInfoXxx foo;
+        StateInfoWww woo;
+
+        public:
+        const StateInfoXxx & get_foo() const { return foo; }
+        StateInfoXxx & get_mutable_foo() { return foo; }
+        void set_foo(const StateInfoXxx & value) { this->foo = value; }
+
+        const StateInfoWww & get_woo() const { return woo; }
+        StateInfoWww & get_mutable_woo() { return woo; }
+        void set_woo(const StateInfoWww & value) { this->woo = value; }
+    };
+}
+
+namespace quicktype {
+    void from_json(const json & j, StateInfoXxx & x);
+    void to_json(json & j, const StateInfoXxx & x);
+
+    void from_json(const json & j, StateInfoWww & x);
+    void to_json(json & j, const StateInfoWww & x);
+
+    void from_json(const json & j, TopLevel & x);
+    void to_json(json & j, const TopLevel & x);
+
+    void from_json(const json & j, FooState & x);
+    void to_json(json & j, const FooState & x);
+
+    void from_json(const json & j, WooState & x);
+    void to_json(json & j, const WooState & x);
+
+    inline void from_json(const json & j, StateInfoXxx& x) {
+        x.set_change_time(j.at("changeTime").get<double>());
+        x.set_state(j.at("state").get<FooState>());
+    }
+
+    inline void to_json(json & j, const StateInfoXxx & x) {
+        j = json::object();
+        j["changeTime"] = x.get_change_time();
+        j["state"] = x.get_state();
+    }
+
+    inline void from_json(const json & j, StateInfoWww& x) {
+        x.set_change_time(j.at("changeTime").get<double>());
+        x.set_state(j.at("state").get<WooState>());
+    }
+
+    inline void to_json(json & j, const StateInfoWww & x) {
+        j = json::object();
+        j["changeTime"] = x.get_change_time();
+        j["state"] = x.get_state();
+    }
+
+    inline void from_json(const json & j, TopLevel& x) {
+        x.set_foo(j.at("foo").get<StateInfoXxx>());
+        x.set_woo(j.at("woo").get<StateInfoWww>());
+    }
+
+    inline void to_json(json & j, const TopLevel & x) {
+        j = json::object();
+        j["foo"] = x.get_foo();
+        j["woo"] = x.get_woo();
+    }
+
+    inline void from_json(const json & j, FooState & x) {
+        if (j == "xx") x = FooState::XX;
+        else if (j == "yy") x = FooState::YY;
+        else { throw std::runtime_error("Cannot deserialize to enumeration \"FooState\""); }
+    }
+
+    inline void to_json(json & j, const FooState & x) {
+        switch (x) {
+            case FooState::XX: j = "xx"; break;
+            case FooState::YY: j = "yy"; break;
+            default: throw std::runtime_error("Unexpected value in enumeration \"FooState\": " + std::to_string(static_cast<int>(x)));
+        }
+    }
+
+    inline void from_json(const json & j, WooState & x) {
+        if (j == "asd") x = WooState::ASD;
+        else if (j == "qwe") x = WooState::QWE;
+        else if (j == "zxc") x = WooState::ZXC;
+        else if (j == "tyu") x = WooState::TYU;
+        else { throw std::runtime_error("Cannot deserialize to enumeration \"WooState\""); }
+    }
+
+    inline void to_json(json & j, const WooState & x) {
+        switch (x) {
+            case WooState::ASD: j = "asd"; break;
+            case WooState::QWE: j = "qwe"; break;
+            case WooState::ZXC: j = "zxc"; break;
+            case WooState::TYU: j = "tyu"; break;
+            default: throw std::runtime_error("Unexpected value in enumeration \"WooState\": " + std::to_string(static_cast<int>(x)));
+        }
+    }
+}
diff --git a/head/schema-csharp/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs b/head/schema-csharp/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs
new file mode 100644
index 0000000..25ef9b0
--- /dev/null
+++ b/head/schema-csharp/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs
@@ -0,0 +1,180 @@
+// <auto-generated />
+//
+// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
+//
+//    using QuickType;
+//
+//    var topLevel = TopLevel.FromJson(jsonString);
+#nullable enable
+#pragma warning disable CS8618
+#pragma warning disable CS8601
+#pragma warning disable CS8602
+#pragma warning disable CS8603
+#pragma warning disable CS8604
+#pragma warning disable CS8625
+#pragma warning disable CS8765
+
+namespace QuickType
+{
+    using System;
+    using System.Collections.Generic;
+
+    using System.Globalization;
+    using Newtonsoft.Json;
+    using Newtonsoft.Json.Converters;
+
+    public partial class TopLevel
+    {
+        [JsonProperty("foo", Required = Required.Always)]
+        public StateInfoXxx Foo { get; set; }
+
+        [JsonProperty("woo", Required = Required.Always)]
+        public StateInfoWww Woo { get; set; }
+    }
+
+    public partial class StateInfoXxx
+    {
+        [JsonProperty("changeTime", Required = Required.Always)]
+        public double ChangeTime { get; set; }
+
+        [JsonProperty("state", Required = Required.Always)]
+        public FooState State { get; set; }
+    }
+
+    public partial class StateInfoWww
+    {
+        [JsonProperty("changeTime", Required = Required.Always)]
+        public double ChangeTime { get; set; }
+
+        [JsonProperty("state", Required = Required.Always)]
+        public WooState State { get; set; }
+    }
+
+    public enum FooState { Xx, Yy };
+
+    public enum WooState { Asd, Qwe, Zxc, Tyu };
+
+    public partial class TopLevel
+    {
+        public static TopLevel FromJson(string json) => JsonConvert.DeserializeObject<TopLevel>(json, QuickType.Converter.Settings);
+    }
+
+    public static partial class Serialize
+    {
+        public static string ToJson(this TopLevel self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
+    }
+
+    internal static partial class Converter
+    {
+        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
+        {
+            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
+            DateParseHandling = DateParseHandling.None,
+            Converters =
+            {
+                FooStateConverter.Singleton,
+                WooStateConverter.Singleton,
+                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
+            },
+        };
+    }
+
+    internal class FooStateConverter : JsonConverter
+    {
+        public override bool CanConvert(Type t) => t == typeof(FooState) || t == typeof(FooState?);
+
+        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
+        {
+            if (reader.TokenType == JsonToken.Null) return null;
+            var value = serializer.Deserialize<string>(reader);
+            switch (value)
+            {
+                case "xx":
+                    return FooState.Xx;
+                case "yy":
+                    return FooState.Yy;
+            }
+            throw new Exception("Cannot unmarshal type FooState");
+        }
+
+        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
+        {
+            if (untypedValue == null)
+            {
+                serializer.Serialize(writer, null);
+                return;
+            }
+            var value = (FooState)untypedValue;
+            switch (value)
+            {
+                case FooState.Xx:
+                    serializer.Serialize(writer, "xx");
+                    return;
+                case FooState.Yy:
+                    serializer.Serialize(writer, "yy");
+                    return;
+            }
+            throw new Exception("Cannot marshal type FooState");
+        }
+
+        public static readonly FooStateConverter Singleton = new FooStateConverter();
+    }
+
+    internal class WooStateConverter : JsonConverter
+    {
+        public override bool CanConvert(Type t) => t == typeof(WooState) || t == typeof(WooState?);
+
+        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
+        {
+            if (reader.TokenType == JsonToken.Null) return null;
+            var value = serializer.Deserialize<string>(reader);
+            switch (value)
+            {
+                case "asd":
+                    return WooState.Asd;
+                case "qwe":
+                    return WooState.Qwe;
+                case "zxc":
+                    return WooState.Zxc;
+                case "tyu":
+                    return WooState.Tyu;
+            }
+            throw new Exception("Cannot unmarshal type WooState");
+        }
+
+        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
+        {
+            if (untypedValue == null)
+            {
+                serializer.Serialize(writer, null);
+                return;
+            }
+            var value = (WooState)untypedValue;
+            switch (value)
+            {
+                case WooState.Asd:
+                    serializer.Serialize(writer, "asd");
+                    return;
+                case WooState.Qwe:
+                    serializer.Serialize(writer, "qwe");
+                    return;
+                case WooState.Zxc:
+                    serializer.Serialize(writer, "zxc");
+                    return;
+                case WooState.Tyu:
+                    serializer.Serialize(writer, "tyu");
+                    return;
+            }
+            throw new Exception("Cannot marshal type WooState");
+        }
+
+        public static readonly WooStateConverter Singleton = new WooStateConverter();
+    }
+}
+#pragma warning restore CS8618
+#pragma warning restore CS8601
+#pragma warning restore CS8602
+#pragma warning restore CS8603
+#pragma warning restore CS8604
+#pragma warning restore CS8625
+#pragma warning restore CS8765
diff --git a/head/schema-csharp-SystemTextJson/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs b/head/schema-csharp-SystemTextJson/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs
new file mode 100644
index 0000000..42a832b
--- /dev/null
+++ b/head/schema-csharp-SystemTextJson/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs
@@ -0,0 +1,276 @@
+// <auto-generated />
+//
+// To parse this JSON data, add NuGet 'System.Text.Json' then do:
+//
+//    using QuickType;
+//
+//    var topLevel = TopLevel.FromJson(jsonString);
+#nullable enable
+#pragma warning disable CS8618
+#pragma warning disable CS8601
+#pragma warning disable CS8602
+#pragma warning disable CS8603
+
+namespace QuickType
+{
+    using System;
+    using System.Collections.Generic;
+
+    using System.Text.Json;
+    using System.Text.Json.Serialization;
+    using System.Globalization;
+
+    public partial class TopLevel
+    {
+        [JsonRequired]
+        [JsonPropertyName("foo")]
+        public StateInfoXxx Foo { get; set; }
+
+        [JsonRequired]
+        [JsonPropertyName("woo")]
+        public StateInfoWww Woo { get; set; }
+    }
+
+    public partial class StateInfoXxx
+    {
+        [JsonRequired]
+        [JsonPropertyName("changeTime")]
+        public double ChangeTime { get; set; }
+
+        [JsonRequired]
+        [JsonPropertyName("state")]
+        public FooState State { get; set; }
+    }
+
+    public partial class StateInfoWww
+    {
+        [JsonRequired]
+        [JsonPropertyName("changeTime")]
+        public double ChangeTime { get; set; }
+
+        [JsonRequired]
+        [JsonPropertyName("state")]
+        public WooState State { get; set; }
+    }
+
+    public enum FooState { Xx, Yy };
+
+    public enum WooState { Asd, Qwe, Zxc, Tyu };
+
+    public partial class TopLevel
+    {
+        public static TopLevel FromJson(string json) => JsonSerializer.Deserialize<TopLevel>(json, QuickType.Converter.Settings);
+    }
+
+    public static partial class Serialize
+    {
+        public static string ToJson(this TopLevel self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
+    }
+
+    internal static partial class Converter
+    {
+        public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
+        {
+            Converters =
+            {
+                FooStateConverter.Singleton,
+                WooStateConverter.Singleton,
+                new DateOnlyConverter(),
+                new TimeOnlyConverter(),
+                IsoDateTimeOffsetConverter.Singleton
+            },
+        };
+    }
+
+    internal class FooStateConverter : JsonConverter<FooState>
+    {
+        public override bool CanConvert(Type t) => t == typeof(FooState);
+
+        public override FooState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        {
+            var value = reader.GetString();
+            switch (value)
+            {
+                case "xx":
+                    return FooState.Xx;
+                case "yy":
+                    return FooState.Yy;
+            }
+            throw new JsonException("Cannot unmarshal type FooState");
+        }
+
+        public override void Write(Utf8JsonWriter writer, FooState value, JsonSerializerOptions options)
+        {
+            switch (value)
+            {
+                case FooState.Xx:
+                    JsonSerializer.Serialize(writer, "xx", options);
+                    return;
+                case FooState.Yy:
+                    JsonSerializer.Serialize(writer, "yy", options);
+                    return;
+            }
+            throw new NotSupportedException("Cannot marshal type FooState");
+        }
+
+        public static readonly FooStateConverter Singleton = new FooStateConverter();
+    }
+
+    internal class WooStateConverter : JsonConverter<WooState>
+    {
+        public override bool CanConvert(Type t) => t == typeof(WooState);
+
+        public override WooState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        {
+            var value = reader.GetString();
+            switch (value)
+            {
+                case "asd":
+                    return WooState.Asd;
+                case "qwe":
+                    return WooState.Qwe;
+                case "zxc":
+                    return WooState.Zxc;
+                case "tyu":
+                    return WooState.Tyu;
+            }
+            throw new JsonException("Cannot unmarshal type WooState");
+        }
+
+        public override void Write(Utf8JsonWriter writer, WooState value, JsonSerializerOptions options)
+        {
+            switch (value)
+            {
+                case WooState.Asd:
+                    JsonSerializer.Serialize(writer, "asd", options);
+                    return;
+                case WooState.Qwe:
+                    JsonSerializer.Serialize(writer, "qwe", options);
+                    return;
+                case WooState.Zxc:
+                    JsonSerializer.Serialize(writer, "zxc", options);
+                    return;
+                case WooState.Tyu:
+                    JsonSerializer.Serialize(writer, "tyu", options);
+                    return;
+            }
+            throw new NotSupportedException("Cannot marshal type WooState");
+        }
+
+        public static readonly WooStateConverter Singleton = new WooStateConverter();
+    }
+    
+    public class DateOnlyConverter : JsonConverter<DateOnly>
+    {
+        private readonly string serializationFormat;
+        public DateOnlyConverter() : this(null) { }
+
+        public DateOnlyConverter(string? serializationFormat)
+        {
+                this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
+        }
+
+        public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        {
+                var value = reader.GetString();
+                return DateOnly.Parse(value!);
+        }
+
+        public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
+                => writer.WriteStringValue(value.ToString(serializationFormat));
+    }
+
+    public class TimeOnlyConverter : JsonConverter<TimeOnly>
+    {
+        private readonly string serializationFormat;
+
+        public TimeOnlyConverter() : this(null) { }
+
+        public TimeOnlyConverter(string? serializationFormat)
+        {
+                this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
+        }
+
+        public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        {
+                var value = reader.GetString();
+                return TimeOnly.Parse(value!);
+        }
+
+        public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
+                => writer.WriteStringValue(value.ToString(serializationFormat));
+    }
+
+    internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
+    {
+        public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
+
+        private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
+
+        private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
+        private string? _dateTimeFormat;
+        private CultureInfo? _culture;
+
+        public DateTimeStyles DateTimeStyles
+        {
+                get => _dateTimeStyles;
+                set => _dateTimeStyles = value;
+        }
+
+        public string? DateTimeFormat
+        {
+                get => _dateTimeFormat ?? string.Empty;
+                set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
+        }
+
+        public CultureInfo Culture
+        {
+                get => _culture ?? CultureInfo.CurrentCulture;
+                set => _culture = value;
+        }
+
+        public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
+        {
+                string text;
+
+
+                if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
+                        || (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
+                {
+                        value = value.ToUniversalTime();
+                }
+
+                text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
+
+                writer.WriteStringValue(text);
+        }
+
+        public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        {
+                string? dateText = reader.GetString();
+
+                if (string.IsNullOrEmpty(dateText) == false)
+                {
+                        if (!string.IsNullOrEmpty(_dateTimeFormat))
+                        {
+                                return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
+                        }
+                        else
+                        {
+                                return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
+                        }
+                }
+                else
+                {
+                        return default(DateTimeOffset);
+                }
+        }
+
+
+        public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
+    }
+}
+#pragma warning restore CS8618
+#pragma warning restore CS8601
+#pragma warning restore CS8602
+#pragma warning restore CS8603
diff --git a/head/schema-csharp-records/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs b/head/schema-csharp-records/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs
new file mode 100644
index 0000000..fd28bee
--- /dev/null
+++ b/head/schema-csharp-records/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.cs
@@ -0,0 +1,180 @@
+// <auto-generated />
+//
+// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
+//
+//    using QuickType;
+//
+//    var topLevel = TopLevel.FromJson(jsonString);
+#nullable enable
+#pragma warning disable CS8618
+#pragma warning disable CS8601
+#pragma warning disable CS8602
+#pragma warning disable CS8603
+#pragma warning disable CS8604
+#pragma warning disable CS8625
+#pragma warning disable CS8765
+
+namespace QuickType
+{
+    using System;
+    using System.Collections.Generic;
+
+    using System.Globalization;
+    using Newtonsoft.Json;
+    using Newtonsoft.Json.Converters;
+
+    public partial record TopLevel
+    {
+        [JsonProperty("foo", Required = Required.Always)]
+        public StateInfoXxx Foo { get; set; }
+
+        [JsonProperty("woo", Required = Required.Always)]
+        public StateInfoWww Woo { get; set; }
+    }
+
+    public partial record StateInfoXxx
+    {
+        [JsonProperty("changeTime", Required = Required.Always)]
+        public double ChangeTime { get; set; }
+
+        [JsonProperty("state", Required = Required.Always)]
+        public FooState State { get; set; }
+    }
+
+    public partial record StateInfoWww
+    {
+        [JsonProperty("changeTime", Required = Required.Always)]
+        public double ChangeTime { get; set; }
+
+        [JsonProperty("state", Required = Required.Always)]
+        public WooState State { get; set; }
+    }
+
+    public enum FooState { Xx, Yy };
+
+    public enum WooState { Asd, Qwe, Zxc, Tyu };
+
+    public partial record TopLevel
+    {
+        public static TopLevel FromJson(string json) => JsonConvert.DeserializeObject<TopLevel>(json, QuickType.Converter.Settings);
+    }
+
+    public static partial class Serialize
+    {
+        public static string ToJson(this TopLevel self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
+    }
+
+    internal static partial class Converter
+    {
+        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
+        {
+            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
+            DateParseHandling = DateParseHandling.None,
+            Converters =
+            {
+                FooStateConverter.Singleton,
+                WooStateConverter.Singleton,
+                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
+            },
+        };
+    }
+
+    internal class FooStateConverter : JsonConverter
+    {
+        public override bool CanConvert(Type t) => t == typeof(FooState) || t == typeof(FooState?);
+
+        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
+        {
+            if (reader.TokenType == JsonToken.Null) return null;
+            var value = serializer.Deserialize<string>(reader);
+            switch (value)
+            {
+                case "xx":
+                    return FooState.Xx;
+                case "yy":
+                    return FooState.Yy;
+            }
+            throw new Exception("Cannot unmarshal type FooState");
+        }
+
+        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
+        {
+            if (untypedValue == null)
+            {
+                serializer.Serialize(writer, null);
+                return;
+            }
+            var value = (FooState)untypedValue;
+            switch (value)
+            {
+                case FooState.Xx:
+                    serializer.Serialize(writer, "xx");
+                    return;
+                case FooState.Yy:
+                    serializer.Serialize(writer, "yy");
+                    return;
+            }
+            throw new Exception("Cannot marshal type FooState");
+        }
+
+        public static readonly FooStateConverter Singleton = new FooStateConverter();
+    }
+
+    internal class WooStateConverter : JsonConverter
+    {
+        public override bool CanConvert(Type t) => t == typeof(WooState) || t == typeof(WooState?);
+
+        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
+        {
+            if (reader.TokenType == JsonToken.Null) return null;
+            var value = serializer.Deserialize<string>(reader);
+            switch (value)
+            {
+                case "asd":
+                    return WooState.Asd;
+                case "qwe":
+                    return WooState.Qwe;
+                case "zxc":
+                    return WooState.Zxc;
+                case "tyu":
+                    return WooState.Tyu;
+            }
+            throw new Exception("Cannot unmarshal type WooState");
+        }
+
+        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
+        {
+            if (untypedValue == null)
+            {
+                serializer.Serialize(writer, null);
+                return;
+            }
+            var value = (WooState)untypedValue;
+            switch (value)
+            {
+                case WooState.Asd:
+                    serializer.Serialize(writer, "asd");
+                    return;
+                case WooState.Qwe:
+                    serializer.Serialize(writer, "qwe");
+                    return;
+                case WooState.Zxc:
+                    serializer.Serialize(writer, "zxc");
+                    return;
+                case WooState.Tyu:
+                    serializer.Serialize(writer, "tyu");
+                    return;
+            }
+            throw new Exception("Cannot marshal type WooState");
+        }
+
+        public static readonly WooStateConverter Singleton = new WooStateConverter();
+    }
+}
+#pragma warning restore CS8618
+#pragma warning restore CS8601
+#pragma warning restore CS8602
+#pragma warning restore CS8603
+#pragma warning restore CS8604
+#pragma warning restore CS8625
+#pragma warning restore CS8765
diff --git a/head/schema-dart/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.dart b/head/schema-dart/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.dart
new file mode 100644
index 0000000..071a408
--- /dev/null
+++ b/head/schema-dart/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.dart
@@ -0,0 +1,105 @@
+// To parse this JSON data, do
+//
+//     final topLevel = topLevelFromJson(jsonString);
+
+import 'dart:convert';
+
+TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
+
+String topLevelToJson(TopLevel data) => json.encode(data.toJson());
+
+class TopLevel {
+    final StateInfoXxx foo;
+    final StateInfoWww woo;
+
+    TopLevel({
+        required this.foo,
+        required this.woo,
+    });
+
+    factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
+        foo: StateInfoXxx.fromJson(json["foo"]),
+        woo: StateInfoWww.fromJson(json["woo"]),
+    );
+
+    Map<String, dynamic> toJson() => {
+        "foo": foo.toJson(),
+        "woo": woo.toJson(),
+    };
+}
+
+class StateInfoXxx {
+    final double changeTime;
+    final FooState state;
+
+    StateInfoXxx({
+        required this.changeTime,
+        required this.state,
+    });
+
+    factory StateInfoXxx.fromJson(Map<String, dynamic> json) => StateInfoXxx(
+        changeTime: json["changeTime"]?.toDouble(),
+        state: fooStateValues.map[json["state"]]!,
+    );
+
+    Map<String, dynamic> toJson() => {
+        "changeTime": changeTime,
+        "state": fooStateValues.reverse[state],
+    };
+}
+
+enum FooState {
+    XX,
+    YY
+}
+
+final fooStateValues = EnumValues({
+    "xx": FooState.XX,
+    "yy": FooState.YY
+});
+
+class StateInfoWww {
+    final double changeTime;
+    final WooState state;
+
+    StateInfoWww({
+        required this.changeTime,
+        required this.state,
+    });
+
+    factory StateInfoWww.fromJson(Map<String, dynamic> json) => StateInfoWww(
+        changeTime: json["changeTime"]?.toDouble(),
+        state: wooStateValues.map[json["state"]]!,
+    );
+
+    Map<String, dynamic> toJson() => {
+        "changeTime": changeTime,
+        "state": wooStateValues.reverse[state],
+    };
+}
+
+enum WooState {
+    ASD,
+    QWE,
+    ZXC,
+    TYU
+}
+
+final wooStateValues = EnumValues({
+    "asd": WooState.ASD,
+    "qwe": WooState.QWE,
+    "zxc": WooState.ZXC,
+    "tyu": WooState.TYU
+});
+
+class EnumValues<T> {
+    Map<String, T> map;
+    late Map<T, String> reverseMap;
+
+    EnumValues(this.map);
+
+    Map<T, String> get reverse {
+            reverseMap = map.map((k, v) => MapEntry(v, k));
+            return reverseMap;
+    }
+}
diff --git a/head/schema-elixir/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.ex b/head/schema-elixir/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.ex
new file mode 100644
index 0000000..0900398
--- /dev/null
+++ b/head/schema-elixir/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.ex
@@ -0,0 +1,208 @@
+# This file was autogenerated using quicktype https://github.com/quicktype/quicktype
+#
+# Add Jason to your mix.exs
+#
+# Decode a JSON string: TopLevel.from_json(data)
+# Encode into a JSON string: TopLevel.to_json(struct)
+
+defmodule FooState do
+  @valid_enum_members [
+    :xx,
+    :yy,
+  ]
+
+  def valid_atom?(value), do: value in @valid_enum_members
+
+  def valid_atom_string?(value) do
+    try do
+        atom = String.to_existing_atom(value)
+        atom in @valid_enum_members
+    rescue
+        ArgumentError -> false
+    end
+  end
+
+  def encode(value) do
+    if valid_atom?(value) do
+        Atom.to_string(value)
+    else
+        {:error, "Unexpected value when encoding atom: #{inspect(value)}"}
+    end
+  end
+
+  def decode(value) do
+    if valid_atom_string?(value) do
+        String.to_existing_atom(value)
+    else
+        {:error, "Unexpected value when decoding atom: #{inspect(value)}"}
+    end
+  end
+
+  def from_json(json) do
+    json
+    |> Jason.decode!()
+    |> decode()
+  end
+
+  def to_json(data) do
+    data
+    |> encode()
+    |> Jason.encode!()
+  end
+end
+
+defmodule StateInfoXxx do
+  @enforce_keys [:change_time, :state]
+  defstruct [:change_time, :state]
+
+  @type t :: %__MODULE__{
+          change_time: float(),
+          state: FooState.t()
+        }
+
+  def from_map(m) do
+    %StateInfoXxx{
+      change_time: m["changeTime"],
+      state: FooState.decode(m["state"]),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "changeTime" => struct.change_time,
+      "state" => FooState.encode(struct.state),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule WooState do
+  @valid_enum_members [
+    :asd,
+    :qwe,
+    :zxc,
+    :tyu,
+  ]
+
+  def valid_atom?(value), do: value in @valid_enum_members
+
+  def valid_atom_string?(value) do
+    try do
+        atom = String.to_existing_atom(value)
+        atom in @valid_enum_members
+    rescue
+        ArgumentError -> false
+    end
+  end
+
+  def encode(value) do
+    if valid_atom?(value) do
+        Atom.to_string(value)
+    else
+        {:error, "Unexpected value when encoding atom: #{inspect(value)}"}
+    end
+  end
+
+  def decode(value) do
+    if valid_atom_string?(value) do
+        String.to_existing_atom(value)
+    else
+        {:error, "Unexpected value when decoding atom: #{inspect(value)}"}
+    end
+  end
+
+  def from_json(json) do
+    json
+    |> Jason.decode!()
+    |> decode()
+  end
+
+  def to_json(data) do
+    data
+    |> encode()
+    |> Jason.encode!()
+  end
+end
+
+defmodule StateInfoWWW do
+  @enforce_keys [:change_time, :state]
+  defstruct [:change_time, :state]
+
+  @type t :: %__MODULE__{
+          change_time: float(),
+          state: WooState.t()
+        }
+
+  def from_map(m) do
+    %StateInfoWWW{
+      change_time: m["changeTime"],
+      state: WooState.decode(m["state"]),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "changeTime" => struct.change_time,
+      "state" => WooState.encode(struct.state),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
+
+defmodule TopLevel do
+  @enforce_keys [:foo, :woo]
+  defstruct [:foo, :woo]
+
+  @type t :: %__MODULE__{
+          foo: StateInfoXxx.t(),
+          woo: StateInfoWWW.t()
+        }
+
+  def from_map(m) do
+    %TopLevel{
+      foo: StateInfoXxx.from_map(m["foo"]),
+      woo: StateInfoWWW.from_map(m["woo"]),
+    }
+  end
+
+  def from_json(json) do
+    json
+          |> Jason.decode!()
+          |> from_map()
+  end
+
+  def to_map(struct) do
+    %{
+      "foo" => StateInfoXxx.to_map(struct.foo),
+      "woo" => StateInfoWWW.to_map(struct.woo),
+    }
+  end
+
+  def to_json(struct) do
+    struct
+          |> to_map()
+          |> Jason.encode!()
+  end
+end
diff --git a/head/schema-elm/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.elm b/head/schema-elm/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.elm
new file mode 100644
index 0000000..4cb7350
--- /dev/null
+++ b/head/schema-elm/test/inputs/schema/percent-encoded-ref.schema/default/QuickType.elm
@@ -0,0 +1,138 @@
+-- To decode the JSON data, add this file to your project, run
+--
+--     elm install NoRedInk/elm-json-decode-pipeline
+--
+-- add these imports
+--
+--     import Json.Decode exposing (decodeString)
+--     import QuickType exposing (quickType)
+--
+-- and you're off to the races with
+--
+--     decodeString quickType myJsonString
+
+module QuickType exposing
+    ( QuickType
+    , quickTypeToString
+    , quickType
+    , StateInfoXxx
+    , StateInfoWWW
+    , FooState(..)
+    , WooState(..)
+    )
+
+import Json.Decode as Jdec
+import Json.Decode.Pipeline as Jpipe
+import Json.Encode as Jenc
+import Dict exposing (Dict)
+
+type alias QuickType =
+    { foo : StateInfoXxx
+    , woo : StateInfoWWW
+    }
+
+type alias StateInfoXxx =
+    { changeTime : Float
+    , state : FooState
+    }
+
+type FooState
+    = Xx
+    | Yy
+
+type alias StateInfoWWW =
+    { changeTime : Float
+    , state : WooState
+    }
+
+type WooState
+    = Asd
+    | Qwe
+    | Zxc
+    | Tyu
+
+-- decoders and encoders
+
+quickTypeToString : QuickType -> String
+quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
+
+quickType : Jdec.Decoder QuickType
+quickType =
+    Jdec.succeed QuickType
+        |> Jpipe.required "foo" stateInfoXxx
+        |> Jpipe.required "woo" stateInfoWWW
+
+encodeQuickType : QuickType -> Jenc.Value
+encodeQuickType x =
+    Jenc.object
+        [ ("foo", encodeStateInfoXxx x.foo)
+        , ("woo", encodeStateInfoWWW x.woo)
+        ]
+
+stateInfoXxx : Jdec.Decoder StateInfoXxx
+stateInfoXxx =
+    Jdec.succeed StateInfoXxx
+        |> Jpipe.required "changeTime" Jdec.float
+        |> Jpipe.required "state" fooState
+
+encodeStateInfoXxx : StateInfoXxx -> Jenc.Value
+encodeStateInfoXxx x =
+    Jenc.object
+        [ ("changeTime", Jenc.float x.changeTime)
+        , ("state", encodeFooState x.state)
+        ]
+
+fooState : Jdec.Decoder FooState
+fooState =
+    Jdec.string
+        |> Jdec.andThen (\str ->
+            case str of
+                "xx" -> Jdec.succeed Xx
+                "yy" -> Jdec.succeed Yy
+                somethingElse -> Jdec.fail <| "Invalid FooState: " ++ somethingElse
+        )
+
+encodeFooState : FooState -> Jenc.Value
+encodeFooState x = case x of
+    Xx -> Jenc.string "xx"
+    Yy -> Jenc.string "yy"
+
+stateInfoWWW : Jdec.Decoder StateInfoWWW
+stateInfoWWW =
+    Jdec.succeed StateInfoWWW
+        |> Jpipe.required "changeTime" Jdec.float
+        |> Jpipe.required "state" wooState
+
+encodeStateInfoWWW : StateInfoWWW -> Jenc.Value
+encodeStateInfoWWW x =
+    Jenc.object
+        [ ("changeTime", Jenc.float x.changeTime)
+        , ("state", encodeWooState x.state)
+        ]
+
+wooState : Jdec.Decoder WooState
+wooState =
+    Jdec.string
+        |> Jdec.andThen (\str ->
+            case str of
+                "asd" -> Jdec.succeed Asd
+                "qwe" -> Jdec.succeed Qwe
+                "zxc" -> Jdec.succeed Zxc
+                "tyu" -> Jdec.succeed Tyu
+                somethingElse -> Jdec.fail <| "Invalid WooState: " ++ somethingElse
+        )
+
+encodeWooState : WooState -> Jenc.Value
+encodeWooState x = case x of
+    Asd -> Jenc.string "asd"
+    Qwe -> Jenc.string "qwe"
+    Zxc -> Jenc.string "zxc"
+    Tyu -> Jenc.string "tyu"
+
+--- encoder helpers
+
+makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
+makeNullableEncoder f m =
+    case m of
+    Just x -> f x
+    Nothing -> Jenc.null
diff --git a/head/schema-flow/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.js b/head/schema-flow/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.js
new file mode 100644
index 0000000..d14fbe8
--- /dev/null
+++ b/head/schema-flow/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.js
@@ -0,0 +1,228 @@
+// @flow
+
+// To parse this data:
+//
+//   const Convert = require("./TopLevel");
+//
+//   const topLevel = Convert.toTopLevel(json);
+//
+// These functions will throw an error if the JSON doesn't
+// match the expected interface, even if the JSON is valid.
+
+export type TopLevel = {
+    foo: StateInfoXxx;
+    woo: StateInfoWWW;
+};
+
+export type StateInfoXxx = {
+    changeTime: number;
+    state:      FooState;
+};
+
+export type FooState =
+      "xx"
+    | "yy";
+
+export type StateInfoWWW = {
+    changeTime: number;
+    state:      WooState;
+};
+
+export type WooState =
+      "asd"
+    | "qwe"
+    | "zxc"
+    | "tyu";
+
+// Converts JSON strings to/from your types
+// and asserts the results of JSON.parse at runtime
+function toTopLevel(json: string): TopLevel {
+    return cast(JSON.parse(json), r("TopLevel"));
+}
+
+function topLevelToJson(value: TopLevel): string {
+    return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
+}
+
+function invalidValue(typ: any, val: any, key: any, parent: any = '') {
+    const prettyTyp = prettyTypeName(typ);
+    const parentText = parent ? ` on ${parent}` : '';
+    const keyText = key ? ` for key "${key}"` : '';
+    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
+}
+
+function prettyTypeName(typ: any): string {
+    if (Array.isArray(typ)) {
+        if (typ.length === 2 && typ[0] === undefined) {
+            return `an optional ${prettyTypeName(typ[1])}`;
+        } else {
+            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
+        }
+    } else if (typeof typ === "object" && typ.literal !== undefined) {
+        return typ.literal;
+    } else {
+        return typeof typ;
+    }
+}
+
+function jsonToJSProps(typ: any): any {
+    if (typ.jsonToJS === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
+        typ.jsonToJS = map;
+    }
+    return typ.jsonToJS;
+}
+
+function jsToJSONProps(typ: any): any {
+    if (typ.jsToJSON === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
+        typ.jsToJSON = map;
+    }
+    return typ.jsToJSON;
+}
+
+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
+    function transformPrimitive(typ: string, val: any): any {
+        if (typeof typ === typeof val) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+
+    function transformUnion(typs: any[], val: any): any {
+        // val must validate against one typ in typs
+        const l = typs.length;
+        for (let i = 0; i < l; i++) {
+            const typ = typs[i];
+            try {
+                return transform(val, typ, getProps);
+            } catch (_) {}
+        }
+        return invalidValue(typs, val, key, parent);
+    }
+
+    function transformEnum(cases: string[], val: any): any {
+        if (cases.indexOf(val) !== -1) return val;
+        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
+    }
+
+    function transformArray(typ: any, val: any): any {
+        // val must be an array with no invalid elements
+        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
+        return val.map(el => transform(el, typ, getProps));
+    }
+
+    function transformDate(val: any): any {
+        if (val === null) {
+            return null;
+        }
+        const d = new Date(val);
+        if (isNaN(d.valueOf())) {
+            return invalidValue(l("Date"), val, key, parent);
+        }
+        return d;
+    }
+
+    function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
+        if (val === null || typeof val !== "object" || Array.isArray(val)) {
+            return invalidValue(l(ref || "object"), val, key, parent);
+        }
+        const result: any = {};
+        Object.getOwnPropertyNames(props).forEach(key => {
+            const prop = props[key];
+            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
+            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
+        });
+        Object.getOwnPropertyNames(val).forEach(key => {
+            if (!Object.prototype.hasOwnProperty.call(props, key)) {
+                result[key] = transform(val[key], additional, getProps, key, ref);
+            }
+        });
+        return result;
+    }
+
+    if (typ === "any") return val;
+    if (typ === null) {
+        if (val === null) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+    if (typ === false) return invalidValue(typ, val, key, parent);
+    let ref: any = undefined;
+    while (typeof typ === "object" && typ.ref !== undefined) {
+        ref = typ.ref;
+        typ = typeMap[typ.ref];
+    }
+    if (Array.isArray(typ)) return transformEnum(typ, val);
+    if (typeof typ === "object") {
+        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
+            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
+            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
+            : invalidValue(typ, val, key, parent);
+    }
+    // Numbers can be parsed by Date but shouldn't be.
+    if (typ === Date && typeof val !== "number") return transformDate(val);
+    return transformPrimitive(typ, val);
+}
+
+function cast<T>(val: any, typ: any): T {
+    return transform(val, typ, jsonToJSProps);
+}
+
+function uncast<T>(val: T, typ: any): any {
+    return transform(val, typ, jsToJSONProps);
+}
+
+function l(typ: any) {
+    return { literal: typ };
+}
+
+function a(typ: any) {
+    return { arrayItems: typ };
+}
+
+function u(...typs: any[]) {
+    return { unionMembers: typs };
+}
+
+function o(props: any[], additional: any) {
+    return { props, additional };
+}
+
+function m(additional: any) {
+    const props: any[] = [];
+    return { props, additional };
+}
+
+function r(name: string) {
+    return { ref: name };
+}
+
+const typeMap: any = {
+    "TopLevel": o([
+        { json: "foo", js: "foo", typ: r("StateInfoXxx") },
+        { json: "woo", js: "woo", typ: r("StateInfoWWW") },
+    ], false),
+    "StateInfoXxx": o([
+        { json: "changeTime", js: "changeTime", typ: 3.14 },
+        { json: "state", js: "state", typ: r("FooState") },
+    ], false),
+    "StateInfoWWW": o([
+        { json: "changeTime", js: "changeTime", typ: 3.14 },
+        { json: "state", js: "state", typ: r("WooState") },
+    ], false),
+    "FooState": [
+        "xx",
+        "yy",
+    ],
+    "WooState": [
+        "asd",
+        "qwe",
+        "zxc",
+        "tyu",
+    ],
+};
+
+module.exports = {
+    "topLevelToJson": topLevelToJson,
+    "toTopLevel": toTopLevel,
+};
diff --git a/head/schema-golang/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.go b/head/schema-golang/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.go
new file mode 100644
index 0000000..2753ca1
--- /dev/null
+++ b/head/schema-golang/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.go
@@ -0,0 +1,50 @@
+// Code generated from JSON Schema using quicktype. DO NOT EDIT.
+// To parse and unparse this JSON data, add this code to your project and do:
+//
+//    topLevel, err := UnmarshalTopLevel(bytes)
+//    bytes, err = topLevel.Marshal()
+
+package main
+
+import "encoding/json"
+
+func UnmarshalTopLevel(data []byte) (TopLevel, error) {
+	var r TopLevel
+	err := json.Unmarshal(data, &r)
+	return r, err
+}
+
+func (r *TopLevel) Marshal() ([]byte, error) {
+	return json.Marshal(r)
+}
+
+type TopLevel struct {
+	Foo StateInfoXxx `json:"foo"`
+	Woo StateInfoWWW `json:"woo"`
+}
+
+type StateInfoXxx struct {
+	ChangeTime float64  `json:"changeTime"`
+	State      FooState `json:"state"`
+}
+
+type StateInfoWWW struct {
+	ChangeTime float64  `json:"changeTime"`
+	State      WooState `json:"state"`
+}
+
+type FooState string
+
+const (
+	Xx FooState = "xx"
+	Yy FooState = "yy"
+)
+
+type WooState string
+
+const (
+	Asd WooState = "asd"
+	Qwe WooState = "qwe"
+	Zxc WooState = "zxc"
+	Tyu WooState = "tyu"
+)
diff --git a/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java
new file mode 100644
index 0000000..a8eb236
--- /dev/null
+++ b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java
@@ -0,0 +1,101 @@
+// To use this code, add the following Maven dependency to your project:
+//
+//
+//     com.fasterxml.jackson.core     : jackson-databind          : 2.9.0
+//     com.fasterxml.jackson.datatype : jackson-datatype-jsr310   : 2.9.0
+//
+// Import this package:
+//
+//     import io.quicktype.Converter;
+//
+// Then you can deserialize a JSON string with
+//
+//     TopLevel data = Converter.fromJsonString(jsonString);
+
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.*;
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.temporal.ChronoField;
+
+public class Converter {
+    // Date-time helpers
+
+    private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_INSTANT)
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetDateTime parseDateTimeString(String str) {
+        return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
+    }
+
+    private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
+            .parseDefaulting(ChronoField.YEAR, 2020)
+            .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
+            .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetTime parseTimeString(String str) {
+        return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
+    }
+    // Serialize/deserialize helpers
+
+    public static TopLevel fromJsonString(String json) throws IOException {
+        return getObjectReader().readValue(json);
+    }
+
+    public static String toJsonString(TopLevel obj) throws JsonProcessingException {
+        return getObjectWriter().writeValueAsString(obj);
+    }
+
+    private static ObjectReader reader;
+    private static ObjectWriter writer;
+
+    private static void instantiateMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.findAndRegisterModules();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        SimpleModule module = new SimpleModule();
+        module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
+            @Override
+            public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseDateTimeString(value);
+            }
+        });
+        mapper.registerModule(module);
+        reader = mapper.readerFor(TopLevel.class);
+        writer = mapper.writerFor(TopLevel.class);
+    }
+
+    private static ObjectReader getObjectReader() {
+        if (reader == null) instantiateMapper();
+        return reader;
+    }
+
+    private static ObjectWriter getObjectWriter() {
+        if (writer == null) instantiateMapper();
+        return writer;
+    }
+}
diff --git a/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java
new file mode 100644
index 0000000..248586f
--- /dev/null
+++ b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java
@@ -0,0 +1,24 @@
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.annotation.*;
+
+public enum FooState {
+    XX, YY;
+
+    @JsonValue
+    public String toValue() {
+        switch (this) {
+            case XX: return "xx";
+            case YY: return "yy";
+        }
+        return null;
+    }
+
+    @JsonCreator
+    public static FooState forValue(String value) throws IOException {
+        if (value.equals("xx")) return XX;
+        if (value.equals("yy")) return YY;
+        throw new IOException("Cannot deserialize FooState");
+    }
+}
diff --git a/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java
new file mode 100644
index 0000000..428d28b
--- /dev/null
+++ b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StateInfoWWW {
+    private double changeTime;
+    private WooState state;
+
+    @JsonProperty("changeTime")
+    public double getChangeTime() { return changeTime; }
+    @JsonProperty("changeTime")
+    public void setChangeTime(double value) { this.changeTime = value; }
+
+    @JsonProperty("state")
+    public WooState getState() { return state; }
+    @JsonProperty("state")
+    public void setState(WooState value) { this.state = value; }
+}
diff --git a/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java
new file mode 100644
index 0000000..6bb4620
--- /dev/null
+++ b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StateInfoXxx {
+    private double changeTime;
+    private FooState state;
+
+    @JsonProperty("changeTime")
+    public double getChangeTime() { return changeTime; }
+    @JsonProperty("changeTime")
+    public void setChangeTime(double value) { this.changeTime = value; }
+
+    @JsonProperty("state")
+    public FooState getState() { return state; }
+    @JsonProperty("state")
+    public void setState(FooState value) { this.state = value; }
+}
diff --git a/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java
new file mode 100644
index 0000000..c14ff23
--- /dev/null
+++ b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class TopLevel {
+    private StateInfoXxx foo;
+    private StateInfoWWW woo;
+
+    @JsonProperty("foo")
+    public StateInfoXxx getFoo() { return foo; }
+    @JsonProperty("foo")
+    public void setFoo(StateInfoXxx value) { this.foo = value; }
+
+    @JsonProperty("woo")
+    public StateInfoWWW getWoo() { return woo; }
+    @JsonProperty("woo")
+    public void setWoo(StateInfoWWW value) { this.woo = value; }
+}
diff --git a/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java
new file mode 100644
index 0000000..af8f01c
--- /dev/null
+++ b/head/schema-java/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java
@@ -0,0 +1,28 @@
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.annotation.*;
+
+public enum WooState {
+    ASD, QWE, ZXC, TYU;
+
+    @JsonValue
+    public String toValue() {
+        switch (this) {
+            case ASD: return "asd";
+            case QWE: return "qwe";
+            case ZXC: return "zxc";
+            case TYU: return "tyu";
+        }
+        return null;
+    }
+
+    @JsonCreator
+    public static WooState forValue(String value) throws IOException {
+        if (value.equals("asd")) return ASD;
+        if (value.equals("qwe")) return QWE;
+        if (value.equals("zxc")) return ZXC;
+        if (value.equals("tyu")) return TYU;
+        throw new IOException("Cannot deserialize WooState");
+    }
+}
diff --git a/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java
new file mode 100644
index 0000000..7d4811b
--- /dev/null
+++ b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java
@@ -0,0 +1,121 @@
+// To use this code, add the following Maven dependency to your project:
+//
+//
+//     com.fasterxml.jackson.core     : jackson-databind          : 2.9.0
+//
+//
+// Import this package:
+//
+//     import io.quicktype.Converter;
+//
+// Then you can deserialize a JSON string with
+//
+//     TopLevel data = Converter.fromJsonString(jsonString);
+
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.*;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+
+public class Converter {
+    // Date-time helpers
+
+    private static final String[] DATE_TIME_FORMATS = {
+            "yyyy-MM-dd'T'HH:mm:ss.SX",
+            "yyyy-MM-dd'T'HH:mm:ss.S",
+            "yyyy-MM-dd'T'HH:mm:ssX",
+            "yyyy-MM-dd'T'HH:mm:ss",
+            "yyyy-MM-dd HH:mm:ss.SX",
+            "yyyy-MM-dd HH:mm:ss.S",
+            "yyyy-MM-dd HH:mm:ssX",
+            "yyyy-MM-dd HH:mm:ss",
+            "HH:mm:ss.SZ",
+            "HH:mm:ss.S",
+            "HH:mm:ssZ",
+            "HH:mm:ss",
+            "yyyy-MM-dd",
+    };
+
+    public static Date parseAllDateTimeString(String str) {
+        for (String format : DATE_TIME_FORMATS) {
+            try {
+                return new SimpleDateFormat(format).parse(str);
+            } catch (Exception ex) {
+                // Ignored
+            }
+        }
+        return null;
+    }
+
+    public static String serializeDateTime(Date datetime) {
+        return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ").format(datetime);
+    }
+
+    public static String serializeDate(Date datetime) {
+        return new SimpleDateFormat("yyyy-MM-dd").format(datetime);
+    }
+
+    public static String serializeTime(Date datetime) {
+        return new SimpleDateFormat("hh:mm:ssZ").format(datetime);
+    }
+    // Serialize/deserialize helpers
+
+    public static TopLevel fromJsonString(String json) throws IOException {
+        return getObjectReader().readValue(json);
+    }
+
+    public static String toJsonString(TopLevel obj) throws JsonProcessingException {
+        return getObjectWriter().writeValueAsString(obj);
+    }
+
+    private static ObjectReader reader;
+    private static ObjectWriter writer;
+
+    private static void instantiateMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.findAndRegisterModules();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        SimpleModule module = new SimpleModule();
+        module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
+            @Override
+            public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseAllDateTimeString(value);
+            }
+        });
+        module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
+            @Override
+            public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseAllDateTimeString(value);
+            }
+        });
+        module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
+            @Override
+            public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseAllDateTimeString(value);
+            }
+        });
+        mapper.registerModule(module);
+        reader = mapper.readerFor(TopLevel.class);
+        writer = mapper.writerFor(TopLevel.class);
+    }
+
+    private static ObjectReader getObjectReader() {
+        if (reader == null) instantiateMapper();
+        return reader;
+    }
+
+    private static ObjectWriter getObjectWriter() {
+        if (writer == null) instantiateMapper();
+        return writer;
+    }
+}
diff --git a/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java
new file mode 100644
index 0000000..248586f
--- /dev/null
+++ b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java
@@ -0,0 +1,24 @@
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.annotation.*;
+
+public enum FooState {
+    XX, YY;
+
+    @JsonValue
+    public String toValue() {
+        switch (this) {
+            case XX: return "xx";
+            case YY: return "yy";
+        }
+        return null;
+    }
+
+    @JsonCreator
+    public static FooState forValue(String value) throws IOException {
+        if (value.equals("xx")) return XX;
+        if (value.equals("yy")) return YY;
+        throw new IOException("Cannot deserialize FooState");
+    }
+}
diff --git a/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java
new file mode 100644
index 0000000..428d28b
--- /dev/null
+++ b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StateInfoWWW {
+    private double changeTime;
+    private WooState state;
+
+    @JsonProperty("changeTime")
+    public double getChangeTime() { return changeTime; }
+    @JsonProperty("changeTime")
+    public void setChangeTime(double value) { this.changeTime = value; }
+
+    @JsonProperty("state")
+    public WooState getState() { return state; }
+    @JsonProperty("state")
+    public void setState(WooState value) { this.state = value; }
+}
diff --git a/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java
new file mode 100644
index 0000000..6bb4620
--- /dev/null
+++ b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StateInfoXxx {
+    private double changeTime;
+    private FooState state;
+
+    @JsonProperty("changeTime")
+    public double getChangeTime() { return changeTime; }
+    @JsonProperty("changeTime")
+    public void setChangeTime(double value) { this.changeTime = value; }
+
+    @JsonProperty("state")
+    public FooState getState() { return state; }
+    @JsonProperty("state")
+    public void setState(FooState value) { this.state = value; }
+}
diff --git a/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java
new file mode 100644
index 0000000..c14ff23
--- /dev/null
+++ b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class TopLevel {
+    private StateInfoXxx foo;
+    private StateInfoWWW woo;
+
+    @JsonProperty("foo")
+    public StateInfoXxx getFoo() { return foo; }
+    @JsonProperty("foo")
+    public void setFoo(StateInfoXxx value) { this.foo = value; }
+
+    @JsonProperty("woo")
+    public StateInfoWWW getWoo() { return woo; }
+    @JsonProperty("woo")
+    public void setWoo(StateInfoWWW value) { this.woo = value; }
+}
diff --git a/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java
new file mode 100644
index 0000000..af8f01c
--- /dev/null
+++ b/head/schema-java-datetime-legacy/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java
@@ -0,0 +1,28 @@
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.annotation.*;
+
+public enum WooState {
+    ASD, QWE, ZXC, TYU;
+
+    @JsonValue
+    public String toValue() {
+        switch (this) {
+            case ASD: return "asd";
+            case QWE: return "qwe";
+            case ZXC: return "zxc";
+            case TYU: return "tyu";
+        }
+        return null;
+    }
+
+    @JsonCreator
+    public static WooState forValue(String value) throws IOException {
+        if (value.equals("asd")) return ASD;
+        if (value.equals("qwe")) return QWE;
+        if (value.equals("zxc")) return ZXC;
+        if (value.equals("tyu")) return TYU;
+        throw new IOException("Cannot deserialize WooState");
+    }
+}
diff --git a/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java
new file mode 100644
index 0000000..a8eb236
--- /dev/null
+++ b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/Converter.java
@@ -0,0 +1,101 @@
+// To use this code, add the following Maven dependency to your project:
+//
+//
+//     com.fasterxml.jackson.core     : jackson-databind          : 2.9.0
+//     com.fasterxml.jackson.datatype : jackson-datatype-jsr310   : 2.9.0
+//
+// Import this package:
+//
+//     import io.quicktype.Converter;
+//
+// Then you can deserialize a JSON string with
+//
+//     TopLevel data = Converter.fromJsonString(jsonString);
+
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.*;
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.temporal.ChronoField;
+
+public class Converter {
+    // Date-time helpers
+
+    private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
+            .appendOptional(DateTimeFormatter.ISO_INSTANT)
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
+            .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetDateTime parseDateTimeString(String str) {
+        return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
+    }
+
+    private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
+            .appendOptional(DateTimeFormatter.ISO_TIME)
+            .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
+            .parseDefaulting(ChronoField.YEAR, 2020)
+            .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
+            .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
+            .toFormatter()
+            .withZone(ZoneOffset.UTC);
+
+    public static OffsetTime parseTimeString(String str) {
+        return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
+    }
+    // Serialize/deserialize helpers
+
+    public static TopLevel fromJsonString(String json) throws IOException {
+        return getObjectReader().readValue(json);
+    }
+
+    public static String toJsonString(TopLevel obj) throws JsonProcessingException {
+        return getObjectWriter().writeValueAsString(obj);
+    }
+
+    private static ObjectReader reader;
+    private static ObjectWriter writer;
+
+    private static void instantiateMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.findAndRegisterModules();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        SimpleModule module = new SimpleModule();
+        module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
+            @Override
+            public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+                String value = jsonParser.getText();
+                return Converter.parseDateTimeString(value);
+            }
+        });
+        mapper.registerModule(module);
+        reader = mapper.readerFor(TopLevel.class);
+        writer = mapper.writerFor(TopLevel.class);
+    }
+
+    private static ObjectReader getObjectReader() {
+        if (reader == null) instantiateMapper();
+        return reader;
+    }
+
+    private static ObjectWriter getObjectWriter() {
+        if (writer == null) instantiateMapper();
+        return writer;
+    }
+}
diff --git a/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java
new file mode 100644
index 0000000..248586f
--- /dev/null
+++ b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/FooState.java
@@ -0,0 +1,24 @@
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.annotation.*;
+
+public enum FooState {
+    XX, YY;
+
+    @JsonValue
+    public String toValue() {
+        switch (this) {
+            case XX: return "xx";
+            case YY: return "yy";
+        }
+        return null;
+    }
+
+    @JsonCreator
+    public static FooState forValue(String value) throws IOException {
+        if (value.equals("xx")) return XX;
+        if (value.equals("yy")) return YY;
+        throw new IOException("Cannot deserialize FooState");
+    }
+}
diff --git a/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java
new file mode 100644
index 0000000..428d28b
--- /dev/null
+++ b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoWWW.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StateInfoWWW {
+    private double changeTime;
+    private WooState state;
+
+    @JsonProperty("changeTime")
+    public double getChangeTime() { return changeTime; }
+    @JsonProperty("changeTime")
+    public void setChangeTime(double value) { this.changeTime = value; }
+
+    @JsonProperty("state")
+    public WooState getState() { return state; }
+    @JsonProperty("state")
+    public void setState(WooState value) { this.state = value; }
+}
diff --git a/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java
new file mode 100644
index 0000000..6bb4620
--- /dev/null
+++ b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/StateInfoXxx.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class StateInfoXxx {
+    private double changeTime;
+    private FooState state;
+
+    @JsonProperty("changeTime")
+    public double getChangeTime() { return changeTime; }
+    @JsonProperty("changeTime")
+    public void setChangeTime(double value) { this.changeTime = value; }
+
+    @JsonProperty("state")
+    public FooState getState() { return state; }
+    @JsonProperty("state")
+    public void setState(FooState value) { this.state = value; }
+}
diff --git a/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java
new file mode 100644
index 0000000..c14ff23
--- /dev/null
+++ b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/TopLevel.java
@@ -0,0 +1,18 @@
+package io.quicktype;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class TopLevel {
+    private StateInfoXxx foo;
+    private StateInfoWWW woo;
+
+    @JsonProperty("foo")
+    public StateInfoXxx getFoo() { return foo; }
+    @JsonProperty("foo")
+    public void setFoo(StateInfoXxx value) { this.foo = value; }
+
+    @JsonProperty("woo")
+    public StateInfoWWW getWoo() { return woo; }
+    @JsonProperty("woo")
+    public void setWoo(StateInfoWWW value) { this.woo = value; }
+}
diff --git a/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java
new file mode 100644
index 0000000..af8f01c
--- /dev/null
+++ b/head/schema-java-lombok/test/inputs/schema/percent-encoded-ref.schema/default/src/main/java/io/quicktype/WooState.java
@@ -0,0 +1,28 @@
+package io.quicktype;
+
+import java.io.IOException;
+import com.fasterxml.jackson.annotation.*;
+
+public enum WooState {
+    ASD, QWE, ZXC, TYU;
+
+    @JsonValue
+    public String toValue() {
+        switch (this) {
+            case ASD: return "asd";
+            case QWE: return "qwe";
+            case ZXC: return "zxc";
+            case TYU: return "tyu";
+        }
+        return null;
+    }
+
+    @JsonCreator
+    public static WooState forValue(String value) throws IOException {
+        if (value.equals("asd")) return ASD;
+        if (value.equals("qwe")) return QWE;
+        if (value.equals("zxc")) return ZXC;
+        if (value.equals("tyu")) return TYU;
+        throw new IOException("Cannot deserialize WooState");
+    }
+}
diff --git a/head/schema-javascript/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.js b/head/schema-javascript/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.js
new file mode 100644
index 0000000..71a5570
--- /dev/null
+++ b/head/schema-javascript/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.js
@@ -0,0 +1,201 @@
+// To parse this data:
+//
+//   const Convert = require("./TopLevel");
+//
+//   const topLevel = Convert.toTopLevel(json);
+//
+// These functions will throw an error if the JSON doesn't
+// match the expected interface, even if the JSON is valid.
+
+// Converts JSON strings to/from your types
+// and asserts the results of JSON.parse at runtime
+function toTopLevel(json) {
+    return cast(JSON.parse(json), r("TopLevel"));
+}
+
+function topLevelToJson(value) {
+    return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
+}
+
+function invalidValue(typ, val, key, parent = '') {
+    const prettyTyp = prettyTypeName(typ);
+    const parentText = parent ? ` on ${parent}` : '';
+    const keyText = key ? ` for key "${key}"` : '';
+    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
+}
+
+function prettyTypeName(typ) {
+    if (Array.isArray(typ)) {
+        if (typ.length === 2 && typ[0] === undefined) {
+            return `an optional ${prettyTypeName(typ[1])}`;
+        } else {
+            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
+        }
+    } else if (typeof typ === "object" && typ.literal !== undefined) {
+        return typ.literal;
+    } else {
+        return typeof typ;
+    }
+}
+
+function jsonToJSProps(typ) {
+    if (typ.jsonToJS === undefined) {
+        const map = {};
+        typ.props.forEach((p) => map[p.json] = { key: p.js, typ: p.typ });
+        typ.jsonToJS = map;
+    }
+    return typ.jsonToJS;
+}
+
+function jsToJSONProps(typ) {
+    if (typ.jsToJSON === undefined) {
+        const map = {};
+        typ.props.forEach((p) => map[p.js] = { key: p.json, typ: p.typ });
+        typ.jsToJSON = map;
+    }
+    return typ.jsToJSON;
+}
+
+function transform(val, typ, getProps, key = '', parent = '') {
+    function transformPrimitive(typ, val) {
+        if (typeof typ === typeof val) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+
+    function transformUnion(typs, val) {
+        // val must validate against one typ in typs
+        const l = typs.length;
+        for (let i = 0; i < l; i++) {
+            const typ = typs[i];
+            try {
+                return transform(val, typ, getProps);
+            } catch (_) {}
+        }
+        return invalidValue(typs, val, key, parent);
+    }
+
+    function transformEnum(cases, val) {
+        if (cases.indexOf(val) !== -1) return val;
+        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
+    }
+
+    function transformArray(typ, val) {
+        // val must be an array with no invalid elements
+        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
+        return val.map(el => transform(el, typ, getProps));
+    }
+
+    function transformDate(val) {
+        if (val === null) {
+            return null;
+        }
+        const d = new Date(val);
+        if (isNaN(d.valueOf())) {
+            return invalidValue(l("Date"), val, key, parent);
+        }
+        return d;
+    }
+
+    function transformObject(props, additional, val) {
+        if (val === null || typeof val !== "object" || Array.isArray(val)) {
+            return invalidValue(l(ref || "object"), val, key, parent);
+        }
+        const result = {};
+        Object.getOwnPropertyNames(props).forEach(key => {
+            const prop = props[key];
+            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
+            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
+        });
+        Object.getOwnPropertyNames(val).forEach(key => {
+            if (!Object.prototype.hasOwnProperty.call(props, key)) {
+                result[key] = transform(val[key], additional, getProps, key, ref);
+            }
+        });
+        return result;
+    }
+
+    if (typ === "any") return val;
+    if (typ === null) {
+        if (val === null) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+    if (typ === false) return invalidValue(typ, val, key, parent);
+    let ref = undefined;
+    while (typeof typ === "object" && typ.ref !== undefined) {
+        ref = typ.ref;
+        typ = typeMap[typ.ref];
+    }
+    if (Array.isArray(typ)) return transformEnum(typ, val);
+    if (typeof typ === "object") {
+        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
+            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
+            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
+            : invalidValue(typ, val, key, parent);
+    }
+    // Numbers can be parsed by Date but shouldn't be.
+    if (typ === Date && typeof val !== "number") return transformDate(val);
+    return transformPrimitive(typ, val);
+}
+
+function cast(val, typ) {
+    return transform(val, typ, jsonToJSProps);
+}
+
+function uncast(val, typ) {
+    return transform(val, typ, jsToJSONProps);
+}
+
+function l(typ) {
+    return { literal: typ };
+}
+
+function a(typ) {
+    return { arrayItems: typ };
+}
+
+function u(...typs) {
+    return { unionMembers: typs };
+}
+
+function o(props, additional) {
+    return { props, additional };
+}
+
+function m(additional) {
+    const props = [];
+    return { props, additional };
+}
+
+function r(name) {
+    return { ref: name };
+}
+
+const typeMap = {
+    "TopLevel": o([
+        { json: "foo", js: "foo", typ: r("StateInfoXxx") },
+        { json: "woo", js: "woo", typ: r("StateInfoWWW") },
+    ], false),
+    "StateInfoXxx": o([
+        { json: "changeTime", js: "changeTime", typ: 3.14 },
+        { json: "state", js: "state", typ: r("FooState") },
+    ], false),
+    "StateInfoWWW": o([
+        { json: "changeTime", js: "changeTime", typ: 3.14 },
+        { json: "state", js: "state", typ: r("WooState") },
+    ], false),
+    "FooState": [
+        "xx",
+        "yy",
+    ],
+    "WooState": [
+        "asd",
+        "qwe",
+        "zxc",
+        "tyu",
+    ],
+};
+
+module.exports = {
+    "topLevelToJson": topLevelToJson,
+    "toTopLevel": toTopLevel,
+};
diff --git a/head/schema-kotlin/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt b/head/schema-kotlin/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt
new file mode 100644
index 0000000..29a82bc
--- /dev/null
+++ b/head/schema-kotlin/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt
@@ -0,0 +1,70 @@
+// To parse the JSON, install Klaxon and do:
+//
+//   val topLevel = TopLevel.fromJson(jsonString)
+
+package quicktype
+
+import com.beust.klaxon.*
+
+private fun <T> Klaxon.convert(k: kotlin.reflect.KClass<*>, fromJson: (JsonValue) -> T, toJson: (T) -> String, isUnion: Boolean = false) =
+    this.converter(object: Converter {
+        @Suppress("UNCHECKED_CAST")
+        override fun toJson(value: Any)        = toJson(value as T)
+        override fun fromJson(jv: JsonValue)   = fromJson(jv) as Any
+        override fun canConvert(cls: Class<*>) = cls == k.java || (isUnion && cls.superclass == k.java)
+    })
+
+private val klaxon = Klaxon()
+    .convert(FooState::class, { FooState.fromValue(it.string!!) }, { "\"${it.value}\"" })
+    .convert(WooState::class, { WooState.fromValue(it.string!!) }, { "\"${it.value}\"" })
+
+data class TopLevel (
+    val foo: StateInfoXxx,
+    val woo: StateInfoWWW
+) {
+    public fun toJson() = klaxon.toJsonString(this)
+
+    companion object {
+        public fun fromJson(json: String) = klaxon.parse<TopLevel>(json)
+    }
+}
+
+data class StateInfoXxx (
+    val changeTime: Double,
+    val state: FooState
+)
+
+enum class FooState(val value: String) {
+    Xx("xx"),
+    Yy("yy");
+
+    companion object {
+        public fun fromValue(value: String): FooState = when (value) {
+            "xx" -> Xx
+            "yy" -> Yy
+            else -> throw IllegalArgumentException()
+        }
+    }
+}
+
+data class StateInfoWWW (
+    val changeTime: Double,
+    val state: WooState
+)
+
+enum class WooState(val value: String) {
+    Asd("asd"),
+    Qwe("qwe"),
+    Zxc("zxc"),
+    Tyu("tyu");
+
+    companion object {
+        public fun fromValue(value: String): WooState = when (value) {
+            "asd" -> Asd
+            "qwe" -> Qwe
+            "zxc" -> Zxc
+            "tyu" -> Tyu
+            else  -> throw IllegalArgumentException()
+        }
+    }
+}
diff --git a/head/schema-kotlin-jackson/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt b/head/schema-kotlin-jackson/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt
new file mode 100644
index 0000000..9b8f8d9
--- /dev/null
+++ b/head/schema-kotlin-jackson/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt
@@ -0,0 +1,92 @@
+// To parse the JSON, install jackson-module-kotlin and do:
+//
+//   val topLevel = TopLevel.fromJson(jsonString)
+
+package quicktype
+
+import com.fasterxml.jackson.annotation.*
+import com.fasterxml.jackson.core.*
+import com.fasterxml.jackson.databind.*
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer
+import com.fasterxml.jackson.databind.module.SimpleModule
+import com.fasterxml.jackson.databind.node.*
+import com.fasterxml.jackson.databind.ser.std.StdSerializer
+import com.fasterxml.jackson.module.kotlin.*
+
+
+@Suppress("UNCHECKED_CAST")
+private fun <T> ObjectMapper.convert(k: kotlin.reflect.KClass<*>, fromJson: (JsonNode) -> T, toJson: (T) -> String, isUnion: Boolean = false) = registerModule(SimpleModule().apply {
+    addSerializer(k.java as Class<T>, object : StdSerializer<T>(k.java as Class<T>) {
+            override fun serialize(value: T, gen: JsonGenerator, provider: SerializerProvider) = gen.writeRawValue(toJson(value))
+    })
+    addDeserializer(k.java as Class<T>, object : StdDeserializer<T>(k.java as Class<T>) {
+            override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = fromJson(p.readValueAsTree())
+    })
+})
+
+val mapper = jacksonObjectMapper().apply {
+    propertyNamingStrategy = PropertyNamingStrategy.LOWER_CAMEL_CASE
+    setSerializationInclusion(JsonInclude.Include.NON_NULL)
+    convert(FooState::class, { FooState.fromValue(it.asText()) }, { "\"${it.value}\"" })
+    convert(WooState::class, { WooState.fromValue(it.asText()) }, { "\"${it.value}\"" })
+}
+
+data class TopLevel (
+    @get:JsonProperty(required=true)@field:JsonProperty(required=true)
+    val foo: StateInfoXxx,
+
+    @get:JsonProperty(required=true)@field:JsonProperty(required=true)
+    val woo: StateInfoWWW
+) {
+    fun toJson() = mapper.writeValueAsString(this)
+
+    companion object {
+        fun fromJson(json: String) = mapper.readValue<TopLevel>(json)
+    }
+}
+
+data class StateInfoXxx (
+    @get:JsonProperty(required=true)@field:JsonProperty(required=true)
+    val changeTime: Double,
+
+    @get:JsonProperty(required=true)@field:JsonProperty(required=true)
+    val state: FooState
+)
+
+enum class FooState(val value: String) {
+    Xx("xx"),
+    Yy("yy");
+
+    companion object {
+        fun fromValue(value: String): FooState = when (value) {
+            "xx" -> Xx
+            "yy" -> Yy
+            else -> throw IllegalArgumentException()
+        }
+    }
+}
+
+data class StateInfoWWW (
+    @get:JsonProperty(required=true)@field:JsonProperty(required=true)
+    val changeTime: Double,
+
+    @get:JsonProperty(required=true)@field:JsonProperty(required=true)
+    val state: WooState
+)
+
+enum class WooState(val value: String) {
+    Asd("asd"),
+    Qwe("qwe"),
+    Zxc("zxc"),
+    Tyu("tyu");
+
+    companion object {
+        fun fromValue(value: String): WooState = when (value) {
+            "asd" -> Asd
+            "qwe" -> Qwe
+            "zxc" -> Zxc
+            "tyu" -> Tyu
+            else  -> throw IllegalArgumentException()
+        }
+    }
+}
diff --git a/head/schema-kotlinx/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt b/head/schema-kotlinx/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt
new file mode 100644
index 0000000..750f395
--- /dev/null
+++ b/head/schema-kotlinx/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.kt
@@ -0,0 +1,43 @@
+// To parse the JSON, install kotlin's serialization plugin and do:
+//
+// val json     = Json { allowStructuredMapKeys = true }
+// val topLevel = json.parse(TopLevel.serializer(), jsonString)
+
+package quicktype
+
+import kotlinx.serialization.*
+import kotlinx.serialization.json.*
+import kotlinx.serialization.descriptors.*
+import kotlinx.serialization.encoding.*
+
+@Serializable
+data class TopLevel (
+    val foo: StateInfoXxx,
+    val woo: StateInfoWWW
+)
+
+@Serializable
+data class StateInfoXxx (
+    val changeTime: Double,
+    val state: FooState
+)
+
+@Serializable
+enum class FooState(val value: String) {
+    @SerialName("xx") Xx("xx"),
+    @SerialName("yy") Yy("yy");
+}
+
+@Serializable
+data class StateInfoWWW (
+    val changeTime: Double,
+    val state: WooState
+)
+
+@Serializable
+enum class WooState(val value: String) {
+    @SerialName("asd") Asd("asd"),
+    @SerialName("qwe") Qwe("qwe"),
+    @SerialName("zxc") Zxc("zxc"),
+    @SerialName("tyu") Tyu("tyu");
+}
diff --git a/head/schema-php/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.php b/head/schema-php/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.php
new file mode 100644
index 0000000..4488329
--- /dev/null
+++ b/head/schema-php/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.php
@@ -0,0 +1,568 @@
+<?php
+declare(strict_types=1);
+
+// This is an autogenerated file:TopLevel
+
+class TopLevel {
+    private StateInfoXxx $foo; // json:foo Required
+    private StateInfoWWW $woo; // json:woo Required
+
+    /**
+     * @param StateInfoXxx $foo
+     * @param StateInfoWWW $woo
+     */
+    public function __construct(StateInfoXxx $foo, StateInfoWWW $woo) {
+        $this->foo = $foo;
+        $this->woo = $woo;
+    }
+
+    /**
+     * @param stdClass $value
+     * @throws Exception
+     * @return StateInfoXxx
+     */
+    public static function fromFoo(stdClass $value): StateInfoXxx {
+        return StateInfoXxx::from($value); /*class*/
+    }
+
+    /**
+     * @throws Exception
+     * @return stdClass
+     */
+    public function toFoo(): stdClass {
+        if (TopLevel::validateFoo($this->foo))  {
+            return $this->foo->to(); /*class*/
+        }
+        throw new Exception('never get to this TopLevel::foo');
+    }
+
+    /**
+     * @param StateInfoXxx
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateFoo(StateInfoXxx $value): bool {
+        $value->validate();
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return StateInfoXxx
+     */
+    public function getFoo(): StateInfoXxx {
+        if (TopLevel::validateFoo($this->foo))  {
+            return $this->foo;
+        }
+        throw new Exception('never get to getFoo TopLevel::foo');
+    }
+
+    /**
+     * @return StateInfoXxx
+     */
+    public static function sampleFoo(): StateInfoXxx {
+        return StateInfoXxx::sample(); /*31:foo*/
+    }
+
+    /**
+     * @param stdClass $value
+     * @throws Exception
+     * @return StateInfoWWW
+     */
+    public static function fromWoo(stdClass $value): StateInfoWWW {
+        return StateInfoWWW::from($value); /*class*/
+    }
+
+    /**
+     * @throws Exception
+     * @return stdClass
+     */
+    public function toWoo(): stdClass {
+        if (TopLevel::validateWoo($this->woo))  {
+            return $this->woo->to(); /*class*/
+        }
+        throw new Exception('never get to this TopLevel::woo');
+    }
+
+    /**
+     * @param StateInfoWWW
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateWoo(StateInfoWWW $value): bool {
+        $value->validate();
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return StateInfoWWW
+     */
+    public function getWoo(): StateInfoWWW {
+        if (TopLevel::validateWoo($this->woo))  {
+            return $this->woo;
+        }
+        throw new Exception('never get to getWoo TopLevel::woo');
+    }
+
+    /**
+     * @return StateInfoWWW
+     */
+    public static function sampleWoo(): StateInfoWWW {
+        return StateInfoWWW::sample(); /*32:woo*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return TopLevel::validateFoo($this->foo)
+        || TopLevel::validateWoo($this->woo);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'foo'} = $this->toFoo();
+        $out->{'woo'} = $this->toWoo();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return TopLevel
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): TopLevel {
+        return new TopLevel(
+         TopLevel::fromFoo($obj->{'foo'})
+        ,TopLevel::fromWoo($obj->{'woo'})
+        );
+    }
+
+    /**
+     * @return TopLevel
+     */
+    public static function sample(): TopLevel {
+        return new TopLevel(
+         TopLevel::sampleFoo()
+        ,TopLevel::sampleWoo()
+        );
+    }
+}
+
+// This is an autogenerated file:StateInfoXxx
+
+class StateInfoXxx {
+    private float $changeTime; // json:changeTime Required
+    private FooState $state; // json:state Required
+
+    /**
+     * @param float $changeTime
+     * @param FooState $state
+     */
+    public function __construct(float $changeTime, FooState $state) {
+        $this->changeTime = $changeTime;
+        $this->state = $state;
+    }
+
+    /**
+     * @param float $value
+     * @throws Exception
+     * @return float
+     */
+    public static function fromChangeTime(float $value): float {
+        return $value; /*float*/
+    }
+
+    /**
+     * @throws Exception
+     * @return float
+     */
+    public function toChangeTime(): float {
+        if (StateInfoXxx::validateChangeTime($this->changeTime))  {
+            return $this->changeTime; /*float*/
+        }
+        throw new Exception('never get to this StateInfoXxx::changeTime');
+    }
+
+    /**
+     * @param float
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateChangeTime(float $value): bool {
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return float
+     */
+    public function getChangeTime(): float {
+        if (StateInfoXxx::validateChangeTime($this->changeTime))  {
+            return $this->changeTime;
+        }
+        throw new Exception('never get to getChangeTime StateInfoXxx::changeTime');
+    }
+
+    /**
+     * @return float
+     */
+    public static function sampleChangeTime(): float {
+        return 31.031; /*31:changeTime*/
+    }
+
+    /**
+     * @param string $value
+     * @throws Exception
+     * @return FooState
+     */
+    public static function fromState(string $value): FooState {
+        return FooState::from($value); /*enum*/
+    }
+
+    /**
+     * @throws Exception
+     * @return string
+     */
+    public function toState(): string {
+        if (StateInfoXxx::validateState($this->state))  {
+            return FooState::to($this->state); /*enum*/
+        }
+        throw new Exception('never get to this StateInfoXxx::state');
+    }
+
+    /**
+     * @param FooState
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateState(FooState $value): bool {
+        FooState::to($value);
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return FooState
+     */
+    public function getState(): FooState {
+        if (StateInfoXxx::validateState($this->state))  {
+            return $this->state;
+        }
+        throw new Exception('never get to getState StateInfoXxx::state');
+    }
+
+    /**
+     * @return FooState
+     */
+    public static function sampleState(): FooState {
+        return FooState::sample(); /*enum*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return StateInfoXxx::validateChangeTime($this->changeTime)
+        || StateInfoXxx::validateState($this->state);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'changeTime'} = $this->toChangeTime();
+        $out->{'state'} = $this->toState();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return StateInfoXxx
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): StateInfoXxx {
+        return new StateInfoXxx(
+         StateInfoXxx::fromChangeTime($obj->{'changeTime'})
+        ,StateInfoXxx::fromState($obj->{'state'})
+        );
+    }
+
+    /**
+     * @return StateInfoXxx
+     */
+    public static function sample(): StateInfoXxx {
+        return new StateInfoXxx(
+         StateInfoXxx::sampleChangeTime()
+        ,StateInfoXxx::sampleState()
+        );
+    }
+}
+
+// This is an autogenerated file:FooState
+
+class FooState {
+    public static FooState $XX;
+    public static FooState $YY;
+    public static function init() {
+        FooState::$XX = new FooState('xx');
+        FooState::$YY = new FooState('yy');
+    }
+    private string $enum;
+    public function __construct(string $enum) {
+        $this->enum = $enum;
+    }
+
+    /**
+     * @param FooState
+     * @return string
+     * @throws Exception
+     */
+    public static function to(FooState $obj): string {
+        switch ($obj->enum) {
+            case FooState::$XX->enum: return 'xx';
+            case FooState::$YY->enum: return 'yy';
+        }
+        throw new Exception('the give value is not an enum-value.');
+    }
+
+    /**
+     * @param mixed
+     * @return FooState
+     * @throws Exception
+     */
+    public static function from($obj): FooState {
+        switch ($obj) {
+            case 'xx': return FooState::$XX;
+            case 'yy': return FooState::$YY;
+        }
+        throw new Exception("Cannot deserialize FooState");
+    }
+
+    /**
+     * @return FooState
+     */
+    public static function sample(): FooState {
+        return FooState::$XX;
+    }
+}
+FooState::init();
+
+// This is an autogenerated file:StateInfoWWW
+
+class StateInfoWWW {
+    private float $changeTime; // json:changeTime Required
+    private WooState $state; // json:state Required
+
+    /**
+     * @param float $changeTime
+     * @param WooState $state
+     */
+    public function __construct(float $changeTime, WooState $state) {
+        $this->changeTime = $changeTime;
+        $this->state = $state;
+    }
+
+    /**
+     * @param float $value
+     * @throws Exception
+     * @return float
+     */
+    public static function fromChangeTime(float $value): float {
+        return $value; /*float*/
+    }
+
+    /**
+     * @throws Exception
+     * @return float
+     */
+    public function toChangeTime(): float {
+        if (StateInfoWWW::validateChangeTime($this->changeTime))  {
+            return $this->changeTime; /*float*/
+        }
+        throw new Exception('never get to this StateInfoWWW::changeTime');
+    }
+
+    /**
+     * @param float
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateChangeTime(float $value): bool {
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return float
+     */
+    public function getChangeTime(): float {
+        if (StateInfoWWW::validateChangeTime($this->changeTime))  {
+            return $this->changeTime;
+        }
+        throw new Exception('never get to getChangeTime StateInfoWWW::changeTime');
+    }
+
+    /**
+     * @return float
+     */
+    public static function sampleChangeTime(): float {
+        return 31.031; /*31:changeTime*/
+    }
+
+    /**
+     * @param string $value
+     * @throws Exception
+     * @return WooState
+     */
+    public static function fromState(string $value): WooState {
+        return WooState::from($value); /*enum*/
+    }
+
+    /**
+     * @throws Exception
+     * @return string
+     */
+    public function toState(): string {
+        if (StateInfoWWW::validateState($this->state))  {
+            return WooState::to($this->state); /*enum*/
+        }
+        throw new Exception('never get to this StateInfoWWW::state');
+    }
+
+    /**
+     * @param WooState
+     * @return bool
+     * @throws Exception
+     */
+    public static function validateState(WooState $value): bool {
+        WooState::to($value);
+        return true;
+    }
+
+    /**
+     * @throws Exception
+     * @return WooState
+     */
+    public function getState(): WooState {
+        if (StateInfoWWW::validateState($this->state))  {
+            return $this->state;
+        }
+        throw new Exception('never get to getState StateInfoWWW::state');
+    }
+
+    /**
+     * @return WooState
+     */
+    public static function sampleState(): WooState {
+        return WooState::sample(); /*enum*/
+    }
+
+    /**
+     * @throws Exception
+     * @return bool
+     */
+    public function validate(): bool {
+        return StateInfoWWW::validateChangeTime($this->changeTime)
+        || StateInfoWWW::validateState($this->state);
+    }
+
+    /**
+     * @return stdClass
+     * @throws Exception
+     */
+    public function to(): stdClass  {
+        $out = new stdClass();
+        $out->{'changeTime'} = $this->toChangeTime();
+        $out->{'state'} = $this->toState();
+        return $out;
+    }
+
+    /**
+     * @param stdClass $obj
+     * @return StateInfoWWW
+     * @throws Exception
+     */
+    public static function from(stdClass $obj): StateInfoWWW {
+        return new StateInfoWWW(
+         StateInfoWWW::fromChangeTime($obj->{'changeTime'})
+        ,StateInfoWWW::fromState($obj->{'state'})
+        );
+    }
+
+    /**
+     * @return StateInfoWWW
+     */
+    public static function sample(): StateInfoWWW {
+        return new StateInfoWWW(
+         StateInfoWWW::sampleChangeTime()
+        ,StateInfoWWW::sampleState()
+        );
+    }
+}
+
+// This is an autogenerated file:WooState
+
+class WooState {
+    public static WooState $ASD;
+    public static WooState $QWE;
+    public static WooState $ZXC;
+    public static WooState $TYU;
+    public static function init() {
+        WooState::$ASD = new WooState('asd');
+        WooState::$QWE = new WooState('qwe');
+        WooState::$ZXC = new WooState('zxc');
+        WooState::$TYU = new WooState('tyu');
+    }
+    private string $enum;
+    public function __construct(string $enum) {
+        $this->enum = $enum;
+    }
+
+    /**
+     * @param WooState
+     * @return string
+     * @throws Exception
+     */
+    public static function to(WooState $obj): string {
+        switch ($obj->enum) {
+            case WooState::$ASD->enum: return 'asd';
+            case WooState::$QWE->enum: return 'qwe';
+            case WooState::$ZXC->enum: return 'zxc';
+            case WooState::$TYU->enum: return 'tyu';
+        }
+        throw new Exception('the give value is not an enum-value.');
+    }
+
+    /**
+     * @param mixed
+     * @return WooState
+     * @throws Exception
+     */
+    public static function from($obj): WooState {
+        switch ($obj) {
+            case 'asd': return WooState::$ASD;
+            case 'qwe': return WooState::$QWE;
+            case 'zxc': return WooState::$ZXC;
+            case 'tyu': return WooState::$TYU;
+        }
+        throw new Exception("Cannot deserialize WooState");
+    }
+
+    /**
+     * @return WooState
+     */
+    public static function sample(): WooState {
+        return WooState::$ASD;
+    }
+}
+WooState::init();
diff --git a/head/schema-pike/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.pmod b/head/schema-pike/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.pmod
new file mode 100644
index 0000000..9f8d9ed
--- /dev/null
+++ b/head/schema-pike/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.pmod
@@ -0,0 +1,94 @@
+// This source has been automatically generated by quicktype.
+// ( https://github.com/quicktype/quicktype )
+//
+// To use this code, simply import it into your project as a Pike module.
+// To JSON-encode your object, you can pass it to `Standards.JSON.encode`
+// or call `encode_json` on it.
+//
+// To decode a JSON string, first pass it to `Standards.JSON.decode`,
+// and then pass the result to `<YourClass>_from_JSON`.
+// It will return an instance of <YourClass>.
+// Bear in mind that these functions have unexpected behavior,
+// and will likely throw an error, if the JSON string does not
+// match the expected interface, even if the JSON itself is valid.
+
+class TopLevel {
+    StateInfoXxx foo; // json: "foo"
+    StateInfoWww woo; // json: "woo"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "foo" : foo,
+            "woo" : woo,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+TopLevel TopLevel_from_JSON(mixed json) {
+    TopLevel retval = TopLevel();
+
+    retval.foo = json["foo"];
+    retval.woo = json["woo"];
+
+    return retval;
+}
+
+class StateInfoXxx {
+    float    change_time; // json: "changeTime"
+    FooState state;       // json: "state"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "changeTime" : change_time,
+            "state" : state,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+StateInfoXxx StateInfoXxx_from_JSON(mixed json) {
+    StateInfoXxx retval = StateInfoXxx();
+
+    retval.change_time = json["changeTime"];
+    retval.state = json["state"];
+
+    return retval;
+}
+
+enum FooState {
+    XX = "xx", // json: "xx"
+    YY = "yy", // json: "yy"
+}
+
+class StateInfoWww {
+    float    change_time; // json: "changeTime"
+    WooState state;       // json: "state"
+
+    string encode_json() {
+        mapping(string:mixed) json = ([
+            "changeTime" : change_time,
+            "state" : state,
+        ]);
+
+        return Standards.JSON.encode(json);
+    }
+}
+
+StateInfoWww StateInfoWww_from_JSON(mixed json) {
+    StateInfoWww retval = StateInfoWww();
+
+    retval.change_time = json["changeTime"];
+    retval.state = json["state"];
+
+    return retval;
+}
+
+enum WooState {
+    ASD = "asd", // json: "asd"
+    QWE = "qwe", // json: "qwe"
+    ZXC = "zxc", // json: "zxc"
+    TYU = "tyu", // json: "tyu"
+}
diff --git a/head/schema-python/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.py b/head/schema-python/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.py
new file mode 100644
index 0000000..1dd9bf0
--- /dev/null
+++ b/head/schema-python/test/inputs/schema/percent-encoded-ref.schema/default/quicktype.py
@@ -0,0 +1,104 @@
+from enum import Enum
+from dataclasses import dataclass
+from typing import Any, TypeVar, Type, cast
+
+
+T = TypeVar("T")
+EnumT = TypeVar("EnumT", bound=Enum)
+
+
+def from_float(x: Any) -> float:
+    assert isinstance(x, (float, int)) and not isinstance(x, bool)
+    return float(x)
+
+
+def to_float(x: Any) -> float:
+    assert isinstance(x, (int, float))
+    return x
+
+
+def to_enum(c: Type[EnumT], x: Any) -> EnumT:
+    assert isinstance(x, c)
+    return x.value
+
+
+def to_class(c: Type[T], x: Any) -> dict:
+    assert isinstance(x, c)
+    return cast(Any, x).to_dict()
+
+
+class FooState(Enum):
+    XX = "xx"
+    YY = "yy"
+
+
+@dataclass
+class StateInfoXxx:
+    change_time: float
+    state: FooState
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'StateInfoXxx':
+        assert isinstance(obj, dict)
+        change_time = from_float(obj.get("changeTime"))
+        state = FooState(obj.get("state"))
+        return StateInfoXxx(change_time, state)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["changeTime"] = to_float(self.change_time)
+        result["state"] = to_enum(FooState, self.state)
+        return result
+
+
+class WooState(Enum):
+    ASD = "asd"
+    QWE = "qwe"
+    ZXC = "zxc"
+    TYU = "tyu"
+
+
+@dataclass
+class StateInfoWWW:
+    change_time: float
+    state: WooState
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'StateInfoWWW':
+        assert isinstance(obj, dict)
+        change_time = from_float(obj.get("changeTime"))
+        state = WooState(obj.get("state"))
+        return StateInfoWWW(change_time, state)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["changeTime"] = to_float(self.change_time)
+        result["state"] = to_enum(WooState, self.state)
+        return result
+
+
+@dataclass
+class TopLevel:
+    foo: StateInfoXxx
+    woo: StateInfoWWW
+
+    @staticmethod
+    def from_dict(obj: Any) -> 'TopLevel':
+        assert isinstance(obj, dict)
+        foo = StateInfoXxx.from_dict(obj.get("foo"))
+        woo = StateInfoWWW.from_dict(obj.get("woo"))
+        return TopLevel(foo, woo)
+
+    def to_dict(self) -> dict:
+        result: dict = {}
+        result["foo"] = to_class(StateInfoXxx, self.foo)
+        result["woo"] = to_class(StateInfoWWW, self.woo)
+        return result
+
+
+def top_level_from_dict(s: Any) -> TopLevel:
+    return TopLevel.from_dict(s)
+
+
+def top_level_to_dict(x: TopLevel) -> Any:
+    return to_class(TopLevel, x)
diff --git a/head/schema-ruby/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.rb b/head/schema-ruby/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.rb
new file mode 100644
index 0000000..de56293
--- /dev/null
+++ b/head/schema-ruby/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.rb
@@ -0,0 +1,119 @@
+# This code may look unusually verbose for Ruby (and it is), but
+# it performs some subtle and complex validation of JSON data.
+#
+# To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
+#
+#   top_level = TopLevel.from_json! "{…}"
+#   puts top_level.woo.change_time
+#
+# If from_json! succeeds, the value returned matches the schema.
+
+require 'json'
+require 'dry-types'
+require 'dry-struct'
+
+module Types
+  include Dry.Types(default: :nominal)
+
+  Hash     = Strict::Hash
+  String   = Strict::String
+  Double   = Strict::Float | Strict::Integer
+  FooState = Strict::String.enum("xx", "yy")
+  WooState = Strict::String.enum("asd", "qwe", "zxc", "tyu")
+end
+
+module FooState
+  Xx = "xx"
+  Yy = "yy"
+end
+
+class StateInfoXxx < Dry::Struct
+  attribute :change_time, Types::Double
+  attribute :state,       Types::FooState
+
+  def self.from_dynamic!(d)
+    d = Types::Hash[d]
+    new(
+      change_time: d.fetch("changeTime"),
+      state:       d.fetch("state"),
+    )
+  end
+
+  def self.from_json!(json)
+    from_dynamic!(JSON.parse(json))
+  end
+
+  def to_dynamic
+    {
+      "changeTime" => change_time,
+      "state"      => state,
+    }
+  end
+
+  def to_json(options = nil)
+    JSON.generate(to_dynamic, options)
+  end
+end
+
+module WooState
+  Asd = "asd"
+  Qwe = "qwe"
+  Zxc = "zxc"
+  Tyu = "tyu"
+end
+
+class StateInfoWWW < Dry::Struct
+  attribute :change_time, Types::Double
+  attribute :state,       Types::WooState
+
+  def self.from_dynamic!(d)
+    d = Types::Hash[d]
+    new(
+      change_time: d.fetch("changeTime"),
+      state:       d.fetch("state"),
+    )
+  end
+
+  def self.from_json!(json)
+    from_dynamic!(JSON.parse(json))
+  end
+
+  def to_dynamic
+    {
+      "changeTime" => change_time,
+      "state"      => state,
+    }
+  end
+
+  def to_json(options = nil)
+    JSON.generate(to_dynamic, options)
+  end
+end
+
+class TopLevel < Dry::Struct
+  attribute :foo, StateInfoXxx
+  attribute :woo, StateInfoWWW
+
+  def self.from_dynamic!(d)
+    d = Types::Hash[d]
+    new(
+      foo: StateInfoXxx.from_dynamic!(d.fetch("foo")),
+      woo: StateInfoWWW.from_dynamic!(d.fetch("woo")),
+    )
+  end
+
+  def self.from_json!(json)
+    from_dynamic!(JSON.parse(json))
+  end
+
+  def to_dynamic
+    {
+      "foo" => foo.to_dynamic,
+      "woo" => woo.to_dynamic,
+    }
+  end
+
+  def to_json(options = nil)
+    JSON.generate(to_dynamic, options)
+  end
+end
diff --git a/head/schema-rust/test/inputs/schema/percent-encoded-ref.schema/default/module_under_test.rs b/head/schema-rust/test/inputs/schema/percent-encoded-ref.schema/default/module_under_test.rs
new file mode 100644
index 0000000..05572b0
--- /dev/null
+++ b/head/schema-rust/test/inputs/schema/percent-encoded-ref.schema/default/module_under_test.rs
@@ -0,0 +1,57 @@
+// Example code that deserializes and serializes the model.
+// extern crate serde;
+// #[macro_use]
+// extern crate serde_derive;
+// extern crate serde_json;
+//
+// use generated_module::TopLevel;
+//
+// fn main() {
+//     let json = r#"{"answer": 42}"#;
+//     let model: TopLevel = serde_json::from_str(&json).unwrap();
+// }
+
+use serde::{Serialize, Deserialize};
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct TopLevel {
+    pub foo: StateInfoXxx,
+
+    pub woo: StateInfoWww,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct StateInfoXxx {
+    pub change_time: f64,
+
+    pub state: FooState,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum FooState {
+    Xx,
+
+    Yy,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct StateInfoWww {
+    pub change_time: f64,
+
+    pub state: WooState,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum WooState {
+    Asd,
+
+    Qwe,
+
+    Zxc,
+
+    Tyu,
+}
diff --git a/head/schema-scala3/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.scala b/head/schema-scala3/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.scala
new file mode 100644
index 0000000..3c88266
--- /dev/null
+++ b/head/schema-scala3/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.scala
@@ -0,0 +1,57 @@
+package quicktype
+
+import io.circe.syntax._
+import io.circe._
+import cats.syntax.functor._
+
+// If a union has a null in, then we'll need this too... 
+type NullValue = None.type
+
+case class TopLevel (
+    val foo : StateInfoXxx,
+    val woo : StateInfoWWW
+) derives Encoder.AsObject, Decoder
+
+case class StateInfoXxx (
+    val changeTime : Double,
+    val state : FooState
+) derives Encoder.AsObject, Decoder
+
+enum FooState : 
+    case Xx
+    case Yy
+
+given Decoder[FooState] = Decoder.decodeString.emap {
+    case "xx" => scala.Right(FooState.Xx)
+    case "yy" => scala.Right(FooState.Yy)
+    case other => scala.Left("invalid FooState: " + other)
+}
+given Encoder[FooState] = Encoder.encodeString.contramap {
+    case FooState.Xx => "xx"
+    case FooState.Yy => "yy"
+}
+
+case class StateInfoWWW (
+    val changeTime : Double,
+    val state : WooState
+) derives Encoder.AsObject, Decoder
+
+enum WooState : 
+    case Asd
+    case Qwe
+    case Zxc
+    case Tyu
+
+given Decoder[WooState] = Decoder.decodeString.emap {
+    case "asd" => scala.Right(WooState.Asd)
+    case "qwe" => scala.Right(WooState.Qwe)
+    case "zxc" => scala.Right(WooState.Zxc)
+    case "tyu" => scala.Right(WooState.Tyu)
+    case other => scala.Left("invalid WooState: " + other)
+}
+given Encoder[WooState] = Encoder.encodeString.contramap {
+    case WooState.Asd => "asd"
+    case WooState.Qwe => "qwe"
+    case WooState.Zxc => "zxc"
+    case WooState.Tyu => "tyu"
+}
diff --git a/head/schema-scala3-upickle/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.scala b/head/schema-scala3-upickle/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.scala
new file mode 100644
index 0000000..72b5009
--- /dev/null
+++ b/head/schema-scala3-upickle/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.scala
@@ -0,0 +1,119 @@
+package quicktype
+
+// Custom pickler so that missing keys and JSON nulls both read as None,
+// and None is left out when writing (upickle's default for Option is a
+// JSON array).
+object OptionPickler extends upickle.AttributeTagged:
+    import upickle.default.Writer
+    import upickle.default.Reader
+    override implicit def OptionWriter[T: Writer]: Writer[Option[T]] =
+        implicitly[Writer[T]].comap[Option[T]] {
+            case None => null.asInstanceOf[T]
+            case Some(x) => x
+        }
+
+    override implicit def OptionReader[T: Reader]: Reader[Option[T]] = {
+        new Reader.Delegate[Any, Option[T]](implicitly[Reader[T]].map(Some(_))){
+        override def visitNull(index: Int) = None
+        }
+    }
+end OptionPickler
+
+// If a union has a null in, then we'll need this too...
+type NullValue = None.type
+given OptionPickler.ReadWriter[NullValue] = OptionPickler.readwriter[ujson.Value].bimap[NullValue](
+    _ => ujson.Null,
+    json => if json.isNull then None else throw new upickle.core.Abort("not null")
+)
+
+object JsonExt:
+    val valueReader = OptionPickler.readwriter[ujson.Value]
+
+    // upickle's built-in primitive readers are lenient -- the numeric and
+    // boolean readers accept strings, and the string reader accepts
+    // numbers and booleans -- so untagged unions need strict readers to
+    // pick the right member.
+    val strictString: OptionPickler.Reader[String] = valueReader.map {
+        case ujson.Str(s) => s
+        case json => throw new upickle.core.Abort("expected string, got " + json)
+    }
+    val strictLong: OptionPickler.Reader[Long] = valueReader.map {
+        case ujson.Num(n) if n.isWhole => n.toLong
+        case json => throw new upickle.core.Abort("expected integer, got " + json)
+    }
+    val strictDouble: OptionPickler.Reader[Double] = valueReader.map {
+        case ujson.Num(n) => n
+        case json => throw new upickle.core.Abort("expected number, got " + json)
+    }
+    val strictBoolean: OptionPickler.Reader[Boolean] = valueReader.map {
+        case ujson.Bool(b) => b
+        case json => throw new upickle.core.Abort("expected boolean, got " + json)
+    }
+
+    def badMerge[T](r1: => OptionPickler.Reader[?], rest: OptionPickler.Reader[?]*): OptionPickler.Reader[T] = valueReader.map { json =>
+        var t: T | Null = null
+        val stack       = Vector.newBuilder[Throwable]
+        (r1 +: rest).foreach { reader =>
+            if t == null then
+            try
+                t = OptionPickler.read[T](json, trace = true)(using reader.asInstanceOf[OptionPickler.Reader[T]])
+            catch
+                case exc => stack += exc
+        }
+        if t != null then t.nn else throw new Exception(json.toString(), stack.result().headOption.getOrElse(null))
+    }
+end JsonExt
+
+
+case class TopLevel (
+    val foo : StateInfoXxx,
+    val woo : StateInfoWWW
+) derives OptionPickler.ReadWriter
+
+case class StateInfoXxx (
+    val changeTime : Double,
+    val state : FooState
+) derives OptionPickler.ReadWriter
+
+enum FooState : 
+    case Xx
+    case Yy
+
+given OptionPickler.ReadWriter[FooState] = OptionPickler.readwriter[String].bimap[FooState](
+    {
+        case FooState.Xx => "xx"
+        case FooState.Yy => "yy"
+    },
+    {
+        case "xx" => FooState.Xx
+        case "yy" => FooState.Yy
+        case other => throw new upickle.core.Abort("invalid FooState: " + other)
+    }
+)
+
+case class StateInfoWWW (
+    val changeTime : Double,
+    val state : WooState
+) derives OptionPickler.ReadWriter
+
+enum WooState : 
+    case Asd
+    case Qwe
+    case Zxc
+    case Tyu
+
+given OptionPickler.ReadWriter[WooState] = OptionPickler.readwriter[String].bimap[WooState](
+    {
+        case WooState.Asd => "asd"
+        case WooState.Qwe => "qwe"
+        case WooState.Zxc => "zxc"
+        case WooState.Tyu => "tyu"
+    },
+    {
+        case "asd" => WooState.Asd
+        case "qwe" => WooState.Qwe
+        case "zxc" => WooState.Zxc
+        case "tyu" => WooState.Tyu
+        case other => throw new upickle.core.Abort("invalid WooState: " + other)
+    }
+)
diff --git a/head/schema-schema/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.schema b/head/schema-schema/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.schema
new file mode 100644
index 0000000..23178df
--- /dev/null
+++ b/head/schema-schema/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.schema
@@ -0,0 +1,75 @@
+{
+    "$schema": "http://json-schema.org/draft-06/schema#",
+    "$ref": "#/definitions/TopLevel",
+    "definitions": {
+        "TopLevel": {
+            "type": "object",
+            "additionalProperties": false,
+            "properties": {
+                "foo": {
+                    "$ref": "#/definitions/StateInfoXxx"
+                },
+                "woo": {
+                    "$ref": "#/definitions/StateInfoWWW"
+                }
+            },
+            "required": [
+                "foo",
+                "woo"
+            ],
+            "title": "TopLevel"
+        },
+        "StateInfoXxx": {
+            "type": "object",
+            "additionalProperties": false,
+            "properties": {
+                "changeTime": {
+                    "type": "number"
+                },
+                "state": {
+                    "$ref": "#/definitions/FooState"
+                }
+            },
+            "required": [
+                "changeTime",
+                "state"
+            ],
+            "title": "StateInfoXxx"
+        },
+        "StateInfoWWW": {
+            "type": "object",
+            "additionalProperties": false,
+            "properties": {
+                "changeTime": {
+                    "type": "number"
+                },
+                "state": {
+                    "$ref": "#/definitions/WooState"
+                }
+            },
+            "required": [
+                "changeTime",
+                "state"
+            ],
+            "title": "StateInfoWWW"
+        },
+        "FooState": {
+            "type": "string",
+            "enum": [
+                "xx",
+                "yy"
+            ],
+            "title": "FooState"
+        },
+        "WooState": {
+            "type": "string",
+            "enum": [
+                "asd",
+                "qwe",
+                "zxc",
+                "tyu"
+            ],
+            "title": "WooState"
+        }
+    }
+}
diff --git a/head/schema-typescript/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.ts b/head/schema-typescript/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.ts
new file mode 100644
index 0000000..93c431e
--- /dev/null
+++ b/head/schema-typescript/test/inputs/schema/percent-encoded-ref.schema/default/TopLevel.ts
@@ -0,0 +1,217 @@
+// To parse this data:
+//
+//   import { Convert, TopLevel } from "./TopLevel";
+//
+//   const topLevel = Convert.toTopLevel(json);
+//
+// These functions will throw an error if the JSON doesn't
+// match the expected interface, even if the JSON is valid.
+
+export interface TopLevel {
+    foo: StateInfoXxx;
+    woo: StateInfoWWW;
+}
+
+export interface StateInfoXxx {
+    changeTime: number;
+    state:      FooState;
+}
+
+export type FooState = "xx" | "yy";
+
+export interface StateInfoWWW {
+    changeTime: number;
+    state:      WooState;
+}
+
+export type WooState = "asd" | "qwe" | "zxc" | "tyu";
+
+// Converts JSON strings to/from your types
+// and asserts the results of JSON.parse at runtime
+export class Convert {
+    public static toTopLevel(json: string): TopLevel {
+        return cast(JSON.parse(json), r("TopLevel"));
+    }
+
+    public static topLevelToJson(value: TopLevel): string {
+        return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
+    }
+}
+
+function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
+    const prettyTyp = prettyTypeName(typ);
+    const parentText = parent ? ` on ${parent}` : '';
+    const keyText = key ? ` for key "${key}"` : '';
+    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
+}
+
+function prettyTypeName(typ: any): string {
+    if (Array.isArray(typ)) {
+        if (typ.length === 2 && typ[0] === undefined) {
+            return `an optional ${prettyTypeName(typ[1])}`;
+        } else {
+            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
+        }
+    } else if (typeof typ === "object" && typ.literal !== undefined) {
+        return typ.literal;
+    } else {
+        return typeof typ;
+    }
+}
+
+function jsonToJSProps(typ: any): any {
+    if (typ.jsonToJS === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
+        typ.jsonToJS = map;
+    }
+    return typ.jsonToJS;
+}
+
+function jsToJSONProps(typ: any): any {
+    if (typ.jsToJSON === undefined) {
+        const map: any = {};
+        typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
+        typ.jsToJSON = map;
+    }
+    return typ.jsToJSON;
+}
+
+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
+    function transformPrimitive(typ: string, val: any): any {
+        if (typeof typ === typeof val) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+
+    function transformUnion(typs: any[], val: any): any {
+        // val must validate against one typ in typs
+        const l = typs.length;
+        for (let i = 0; i < l; i++) {
+            const typ = typs[i];
+            try {
+                return transform(val, typ, getProps);
+            } catch (_) {}
+        }
+        return invalidValue(typs, val, key, parent);
+    }
+
+    function transformEnum(cases: string[], val: any): any {
+        if (cases.indexOf(val) !== -1) return val;
+        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
+    }
+
+    function transformArray(typ: any, val: any): any {
+        // val must be an array with no invalid elements
+        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
+        return val.map(el => transform(el, typ, getProps));
+    }
+
+    function transformDate(val: any): any {
+        if (val === null) {
+            return null;
+        }
+        const d = new Date(val);
+        if (isNaN(d.valueOf())) {
+            return invalidValue(l("Date"), val, key, parent);
+        }
+        return d;
+    }
+
+    function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
+        if (val === null || typeof val !== "object" || Array.isArray(val)) {
+            return invalidValue(l(ref || "object"), val, key, parent);
+        }
+        const result: any = {};
+        Object.getOwnPropertyNames(props).forEach(key => {
+            const prop = props[key];
+            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
+            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
+        });
+        Object.getOwnPropertyNames(val).forEach(key => {
+            if (!Object.prototype.hasOwnProperty.call(props, key)) {
+                result[key] = transform(val[key], additional, getProps, key, ref);
+            }
+        });
+        return result;
+    }
+
+    if (typ === "any") return val;
+    if (typ === null) {
+        if (val === null) return val;
+        return invalidValue(typ, val, key, parent);
+    }
+    if (typ === false) return invalidValue(typ, val, key, parent);
+    let ref: any = undefined;
+    while (typeof typ === "object" && typ.ref !== undefined) {
+        ref = typ.ref;
+        typ = typeMap[typ.ref];
+    }
+    if (Array.isArray(typ)) return transformEnum(typ, val);
+    if (typeof typ === "object") {
+        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
+            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
+            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
+            : invalidValue(typ, val, key, parent);
+    }
+    // Numbers can be parsed by Date but shouldn't be.
+    if (typ === Date && typeof val !== "number") return transformDate(val);
+    return transformPrimitive(typ, val);
+}
+
+function cast<T>(val: any, typ: any): T {
+    return transform(val, typ, jsonToJSProps);
+}
+
+function uncast<T>(val: T, typ: any): any {
+    return transform(val, typ, jsToJSONProps);
+}
+
+function l(typ: any) {
+    return { literal: typ };
+}
+
+function a(typ: any) {
+    return { arrayItems: typ };
+}
+
+function u(...typs: any[]) {
+    return { unionMembers: typs };
+}
+
+function o(props: any[], additional: any) {
+    return { props, additional };
+}
+
+function m(additional: any) {
+    const props: any[] = [];
+    return { props, additional };
+}
+
+function r(name: string) {
+    return { ref: name };
+}
+
+const typeMap: any = {
+    "TopLevel": o([
+        { json: "foo", js: "foo", typ: r("StateInfoXxx") },
+        { json: "woo", js: "woo", typ: r("StateInfoWWW") },
+    ], false),
+    "StateInfoXxx": o([
+        { json: "changeTime", js: "changeTime", typ: 3.14 },
+        { json: "state", js: "state", typ: r("FooState") },
+    ], false),
+    "StateInfoWWW": o([
+        { json: "changeTime", js: "changeTime", typ: 3.14 },
+        { json: "state", js: "state", typ: r("WooState") },
+    ], false),
+    "FooState": [
+        "xx",
+        "yy",
+    ],
+    "WooState": [
+        "asd",
+        "qwe",
+        "zxc",
+        "tyu",
+    ],
+};
