question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request body standardization with multiple content types accepted

See original GitHub issue

I use Autorest and the ModelerFour plugin to generate resource types for the Azure Bicep project. ModelerFour has not been able to process some ARM swagger documents since https://github.com/Azure/autorest/pull/4405; specifically, resources under the Microsoft.Web namespace can no longer be generated because the ARM resource provider can consume the same object structure as either JSON or form data.

Should ModelerFour permit requests with the same structured input over two different content types? I saw that there is a special case to allow operations to consume both XML and JSON but was wondering if a more general solution would be possible.

Before asking the question:

  • have you checked the faq, the documentation in the docs folder and couldn’t find the information there
  • have you checked existing issues for a similar question?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
timotheeguerincommented, May 27, 2022

It is possible in openapi3 to do, what it means here is that the payload schema is the same but it can be serialized as json or formData. I was just asking on what was m4 behavior before if you know, was it just ignoring the formData type and acting like this was just application/json. As far as I know the generators don’t support different serializion types for the same schema which is why this check is there complaining but we could have the same special case as with xml where if json is specified it takes precendence

0reactions
jeskewcommented, May 27, 2022

Hey @jeskew can you confirm this PR resolve the issue following the instruction on this comment #4543 (comment)

It does! Thanks for the quick work on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describing Request Body - Swagger
The requestBody is more flexible in that it lets you consume different media types, such as JSON, XML, form data, plain text, and...
Read more >
Does the HTTP Protocol support multiple content types in ...
No. As pointed out in the accepted answer, the header value itself does not allow for multiple values, and ...
Read more >
4 The Content-Type Header Field
The Content-Type header field is used to specify the nature of the data in the body of an entity, by giving type and...
Read more >
RFC 7231: Hypertext Transfer Protocol (HTTP/1.1)
This document defines the semantics of HTTP/1.1 messages, as expressed by request methods, request header fields, response status codes, and response header ...
Read more >
4. Metadata Design - REST API Design Rulebook [Book]
The Content-Type header names the type of data found within a request or response message’s body. The value of this header is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found