FasterXML / jackson-module-jsonSchema

Module for generating JSON Schema (v3) definitions from POJOs
371 stars 135 forks source link

Add property `mediaType` for `StringSchema` #114

Closed sukhrajm closed 8 years ago

sukhrajm commented 8 years ago

Changes to add mediatype to the StringSchema according to json schema 0.3. Media type is specified in the schema but previously there was no way to set the media type on a StringSchema.

cowtowncoder commented 8 years ago

Quick question: is this only applicable for StringSchema? I see one reference from HyperSchema.

cowtowncoder commented 8 years ago

Hmmh. Actually, looking at https://tools.ietf.org/html/draft-zyp-json-schema-03#section-6 I only see references to mediaType in HyperSchema section... which makes me wonder if this change actually should be made at all. Why do you think it belong in StringSchema?

sukhrajm commented 8 years ago

We were using it for a property represented by a stringschema. There were other properties that we used in a StringSchema (maxLength, minLength, pattern). I was thinking that i could describe what media type that property would hold.

cowtowncoder commented 8 years ago

@sukhrajm what I want to know is simply how mediaType should be handled in general: and since HyperSchema does contain it, if that would work. If not, whether this should be something that all schema types should have. So basically looking at this from JSON Schema logical model perspective: not just what your particular use case needs (although obviously that is what matters to you, nothing wrong with that).

So I am not against this addition but I would like to know the bigger picture first.

I'll see if anyone on the mailing list can help.

sukhrajm commented 8 years ago

It seems like mediatype should belong with any of the simple types so that it can be set for any property rather than just a link. Just seems restrictive that is just part of a linkdescription object.