Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/twelve-actors-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@redocly/respect-core": patch
"@redocly/cli": patch
---

Corrected an issue where `Respect` did not properly JSON-encode request bodies for custom content-types containing numbers.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ npm i -g redocly-cli.tgz
(cd tests/smoke/basic/ && redocly build-docs openapi.yaml -o pre-built/redoc.html)
```

Don't forget to visually check the [changes](tests/smoke/basic/pre-built/redoc.html) in browser.
For other commands you'd have to do something similar.

### Performance benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('normalizeHeaders', () => {
});

describe('isJsonContentType', () => {
it('should return true if json mime type', () => {
it('should return true if json content type', () => {
const result = isJsonContentType('application/json');
expect(result).toEqual(true);
});
Expand All @@ -42,10 +42,15 @@ describe('isJsonContentType', () => {
expect(result).toEqual(true);
});

it('should return false if not json mime type', () => {
it('should return false if not json content type', () => {
const result = isJsonContentType('application/xml');
expect(result).toEqual(false);
});

it('should return true if json content type with numbers', () => {
const result = isJsonContentType('application/ast.some.test.value-3v3.info+json');
expect(result).toEqual(true);
});
});

describe('isXmlContentType', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/respect-core/src/utils/api-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function normalizeHeaders(headers: Record<string, string> | undefined) {
}

export function isJsonContentType(contentType: string) {
return /^application\/([a-z.-]+\+)?json$/.test(contentType);
return /^application\/([a-z0-9.-]+\+)?json$/.test(contentType);
}

export function isXmlContentType(contentType: string) {
Expand Down
Loading
Loading