private static CodegenType InternalMakeCodegenType(string name, Schema schema) { if (!string.IsNullOrWhiteSpace(schema.ReferenceType)) { throw new InvalidOperationException("We don't support de-referencing here."); } if (!(schema.Type?.Count >= 1)) { throw new InvalidOperationException("This Schema does not represent a type"); } if (schema.AdditionalProperties == null) { if (schema.Type.Count == 1 && !schema.Type[0].IsReference && schema.Type[0].Name == "array") { return(ArrayValueCodegenTypeFactory.MakeCodegenType(name, schema)); } return(SingleValueCodegenTypeFactory.MakeCodegenType(name, schema)); } if (schema.Type.Count == 1 && schema.Type[0].Name == "object") { return(MakeDictionaryType(name, schema)); } throw new InvalidOperationException(); }
private static CodegenType InternalMakeCodegenType(string name, Schema schema) { if (schema.Disallowed != null || schema.Pattern != null) { throw new NotImplementedException(); } if (schema.ReferenceType != null) { throw new InvalidOperationException("We don't support de-referencing here."); } if (!(schema.Type?.Length >= 1)) { throw new InvalidOperationException("This Schema does not represent a type"); } if (schema.DictionaryValueType == null) { if (schema.Type.Length == 1 && !schema.Type[0].IsReference && schema.Type[0].Name == "array") { return(ArrayValueCodegenTypeFactory.MakeCodegenType(name, schema)); } return(SingleValueCodegenTypeFactory.MakeCodegenType(name, schema)); } if (schema.Type.Length == 1 && schema.Type[0].Name == "object") { return(MakeDictionaryType(name, schema)); } throw new InvalidOperationException(); }
private static CodegenType InternalMakeCodegenType(string name, JSchema schema) { if (schema.Reference != null) { throw new InvalidOperationException("We don't support de-referencing here."); } if (schema.AdditionalProperties == null) { if (schema.Type == JSchemaType.Array) { return(ArrayValueCodegenTypeFactory.MakeCodegenType(name, schema)); } return(SingleValueCodegenTypeFactory.MakeCodegenType(name, schema)); } if (schema.Type == JSchemaType.Object) { return(MakeDictionaryType(name, schema)); } throw new InvalidOperationException(); }