Generate XSD from types in assembly with xsd.exe, having dataannotation attributes on properties

StackOverflow https://stackoverflow.com/questions/10285852

Domanda

I was hoping to reuse some viewmodel classes with dataannotations to generate xsd files for the purpose of validating (and documenting) xml files from 3rd party systems. Xsd.exe generates the .xsd files fine, but dataannotation attributes like [Required] are not reflected in the xsd with f.ex. minOccurs=1.

What options (if any) do I have here? The "easiest" would probably be to create my own xsd generation using reflection. Or could I get away with just creating the extra validation attributes in a separate xsd and use both when validating xml files towards it?

Any other ideas?

È stato utile?

Soluzione

I don't know of any other solution.

I did write an XSD generator using reflection (to be able to include comments in my case) - it is quite a lot of work but definitely feasible.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top