-
Notifications
You must be signed in to change notification settings - Fork 249
Add Content-Type and Accept headers where necessary #2349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Content-Type and Accept headers where necessary #2349
Conversation
✅ Deploy Preview for stoplight-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for stoplight-elements-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
I think this should also close #2351 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice and appreciated - yes @mnaumanali94 I do think this will fix the other issue as well - @provokateurin I think the test failures are pretty straightforward to fix, take a look at my comment and thanks for contributing!
849fbb9
to
de40cd3
Compare
@dotslashderek Tests don't seem to run? |
@provokateurin yeah - we're trying to figure out what's going on with the CircleCI pipeline. I pushed a couple changes to trigger runs, then fixed the four TryIt failures. If you want to take a look at the HttpOperation test that's failing, I'd like to see what happens with the pipeline when you push a new commit. Otherwise no worries I'll take another look at this in the next day or two. Thanks again! |
17b5189
to
2bf99a5
Compare
@dotslashderek I dropped your changes because I made a mistake with the Accept header where it still added it with 0 accepted mime types. Afterwards your fixes for the tests were breaking it again, so I did it properly. Tests work locally now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment, but a second request - could you add a couple quick unit tests around getAcceptedMimeTypes (that's why I exported
it in the suggestion) to build-request.spec.ts? - could be as simple as:
describe('getAcceptedMimeTypes', () => {
const operationSingleResponse: IHttpOperation = {
id: 'adsf',
method: 'GET',
path: '/a/path',
responses: [
{
id: 'responseA',
code: '200',
contents: [
{
id: 'adsf',
mediaType: 'application/json',
},
{
id: 'dfvs',
mediaType: 'application/json',
},
{
id: 'aaaa',
mediaType: 'multipart/form-data',
},
],
},
],
};
const operationMultipleResponses: IHttpOperation = {
id: 'sfdf',
method: 'POST',
path: '/a/nother/path',
responses: [
{
id: 'responseA',
code: '200',
contents: [
{
id: 'adsf',
mediaType: 'application/json',
},
{
id: 'dfvs',
mediaType: 'application/json',
},
],
},
{
id: 'responseB',
code: '200',
contents: [
{
id: 'adsf',
mediaType: 'application/json',
},
{
id: 'dfvs',
mediaType: 'multipart/form-data',
},
],
},
{
id: 'responseC',
code: '200',
contents: [
{
id: 'dfvs',
mediaType: 'multipart/form-data',
},
],
},
{
id: 'responseB',
code: '200',
contents: [
{
id: 'adsf',
mediaType: 'text/json',
},
{
id: 'dfvs',
mediaType: 'multipart/form-data',
},
],
},
],
};
it('Handles a single response with duplicates', () => {
expect(getAcceptedMimeTypes(operationSingleResponse)).toStrictEqual(['application/json', 'multipart/form-data']);
});
it('Handles multiple responses and dedups appropriately', () => {
expect(getAcceptedMimeTypes(operationMultipleResponses)).toStrictEqual([
'application/json',
'multipart/form-data',
'text/json',
]);
});
});
Thanks! (And for fixing things properly w/ the TryIt tests 🙂 )
2bf99a5
to
5916c3d
Compare
@dotslashderek Added the tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @provokateurin - thanks for taking care of this!
Missing reviews or ready to merge? |
Ready to merge! |
Thanks a lot! |
Closes #1798