autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Validation rule for the produces/consumes types that AutoRest supports

Open tbombach opened this issue 10 years ago • 3 comments

Right now, AutoRest only supports JSON across the wire. Swagger specs can contain any MIME type, but we'd like to let the author know that AutoRest will not make requests using that MIME type.

This is indicated in Swagger files with produces and consumes sections. We should have a validation rule that each MIME type in that array is application/json. If it's not, we'll show a message that AutoRest won't use that MIME type in the generated code. I think it should be either a Warning or Info level message, since it doesn't break AutoRest to list extra MIME types.

tbombach avatar Oct 06 '16 23:10 tbombach

What about supporting parameters on the application/json MIME type? For example, OData services can support varying levels of metadata. For example, application/json;odata.metadata=none returns less metadata than application/json;odata.metadata=minimal. Is there any reason AutoRest can't use MIME types like these?

bitsforthought avatar Oct 07 '16 00:10 bitsforthought

Good point - the validation rule should make sure that the MIME type starts with "application/json", not that it matches "application/json" exactly. This rule should use the same logic that's used during operation building: https://github.com/Azure/autorest/blob/master/src/modeler/AutoRest.Swagger/OperationBuilder.cs#L408

Thanks @brjohnstmsft!

tbombach avatar Oct 07 '16 16:10 tbombach

Issue fixed here https://github.com/Azure/autorest/pull/1507

dsgouda avatar Oct 28 '16 18:10 dsgouda