I have a class,
public class Instance : IResource
{
public Dictionary<string, object> Value { get; set; }
and it is mapped to
interface Instance {
Value: System.Collections.Generic.KeyValuePair[];
interface KeyValuePair {
Key: any;
Value: any;
}
I would have expected
interface Instance {
Value: any;
or
interface Instance {
Value: {[index:string]:any};
How can I change the generation?
Also, how can I skip the name space in the generation?
Here's a more generalized (and updated) solution that builds off of Markus Jarderot's answer:
Use it like this:
N.B. this only fixes type signatures of properties (or fields) that have dictionary types. Also definitions for
IDictionary
are not automatically emitted, you'd have to add them manually:Collection types (any type implementing
IEnumerable
) is converted to arrays.Dictionary<>
implementsIEnumerable<KeyValuePair<>>
and thus is converted to an array. The item-type is then expanded to its fully qualified name (FQN):System.Collections.Generic.KeyValuePair
.Using Type Converters will let you change the type-name, but not the FQN. So it is only applicable to local types. In the case of dictionaries, you can't change the item type by inheritance.
You could either create a new dictionary type, without inheriting from
Dictionary<>
. Another way around this problem, is to also use Type Formatters:A quick and dirty workaround is to use a regex to alter output:
Using
Transforms a field
to