{"record":{"id":"a671a57a975de36d","repo":"RicoSuter/NSwag","slug":"the-given-schema-type-is-not-supported","errorCode":null,"errorMessage":"The given schema type is not supported.","messagePattern":"The given schema type is not supported\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/NSwag.Core/OpenApiDocument.Serialization.cs","lineNumber":110,"sourceCode":"                //resolver.IgnoreProperty(typeof(SwaggerResponse), \"produces\");\n\n                resolver.IgnoreProperty(typeof(OpenApiDocument), \"definitions\");\n                resolver.IgnoreProperty(typeof(OpenApiDocument), \"parameters\");\n                resolver.IgnoreProperty(typeof(OpenApiDocument), \"responses\");\n                resolver.IgnoreProperty(typeof(OpenApiDocument), \"securityDefinitions\");\n\n                resolver.IgnoreProperty(typeof(OpenApiResponse), \"schema\");\n                resolver.IgnoreProperty(typeof(OpenApiResponse), \"examples\");\n                resolver.IgnoreProperty(typeof(OpenApiResponse), \"x-nullable\");\n\n                resolver.IgnoreProperty(typeof(OpenApiSecurityScheme), \"flow\");\n                resolver.IgnoreProperty(typeof(OpenApiSecurityScheme), \"authorizationUrl\");\n                resolver.IgnoreProperty(typeof(OpenApiSecurityScheme), \"tokenUrl\");\n                resolver.IgnoreProperty(typeof(OpenApiSecurityScheme), \"scopes\");\n            }\n            else\n            {\n                throw new ArgumentException(\"The given schema type is not supported.\");\n            }\n\n            return resolver;\n        }\n\n        private ObservableCollection<OpenApiSchema> _schemes = [];\n        internal List<string> _consumes = [];\n        internal List<string> _produces = [];\n\n        /// <summary>Gets or sets the host (name or ip) serving the API (Swagger only).</summary>\n        [JsonProperty(PropertyName = \"host\", Order = 5, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]\n        public string Host\n        {\n            get => Servers?.FirstOrDefault()?.Url?.Replace(\"http://\", \"\").Replace(\"https://\", \"\").Split('/')[0];\n            set => UpdateServers(Schemes, value, BasePath);\n        }\n\n        /// <summary>Gets or sets the base path on which the API is served, which is relative to the <see cref=\"Host\"/>.</summary>","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/RicoSuter/NSwag/blob/63daf8fcc3a25151b62eb4b326a1e8ea048a0d41/src/NSwag.Core/OpenApiDocument.Serialization.cs#L92-L128","documentation":"CreateJsonSerializerContractResolver configures JSON serializer settings per schema type but only has branches for Swagger2 and OpenApi3; anything else throws ArgumentException('The given schema type is not supported.'). It is a private factory called by the cached resolver providers for known types.","triggerScenarios":"Invoking the contract resolver factory with a SchemaType other than Swagger2/OpenApi3, typically via GetJsonSerializerContractResolver with an invalid enum value.","commonSituations":"A SchemaType field set from unvalidated input, or a new enum value added in a newer NSwag version being passed to an older runtime.","solutions":["Pass only SchemaType.Swagger2 or SchemaType.OpenApi3","Validate/normalize the schema type before serialization","Upgrade NSwag if a newer schema type is expected to be supported"],"exampleFix":"// before\nvar resolver = GetJsonSerializerContractResolver(schemaType);\n// after\nif (schemaType != SchemaType.Swagger2 && schemaType != SchemaType.OpenApi3)\n    throw new ArgumentException($\"Unsupported schema type: {schemaType}\");\nvar resolver = GetJsonSerializerContractResolver(schemaType);","handlingStrategy":"validation","validationCode":"var supported = new[] { SchemaType.Swagger2, SchemaType.OpenApi3 };\nif (!supported.Contains(schemaType)) throw new ArgumentException(nameof(schemaType));","typeGuard":"bool resolverSupported = schemaType == SchemaType.Swagger2 || schemaType == SchemaType.OpenApi3;","tryCatchPattern":null,"preventionTips":["Keep SchemaType sources (config, CLI flags) validated against supported enum values","Pin NSwag version and enum usage consistently across projects"],"tags":["nswag","schema-type","unsupported"],"backgroundTag":"unsupported-enum-value","analyzedSha":"63daf8fcc3a25151b62eb4b326a1e8ea048a0d41","analyzedAt":"2026-09-14T11:38:15.205Z","contentChangedAt":"2026-09-14T11:38:15.205Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}