Skip to content
Open
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
14 changes: 10 additions & 4 deletions src/N8NPropertiesBuilder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ test('query param - schema', () => {
]);
});

test('query param - content', () => {
const contentTypes = [
['application/json'],
['application/openapi+json'],
['application/vnd.api+json'],
];

test.each(contentTypes)('query param - content', (contentType) => {
const paths = {
'/api/entities': {
get: {
Expand All @@ -160,7 +166,7 @@ test('query param - content', () => {
example: false,
description: 'Filter description',
content: {
'application/json': {
[contentType]: {
schema: {
$ref: '#/components/schemas/Entity',
},
Expand Down Expand Up @@ -501,15 +507,15 @@ test('path param', () => {
]);
});

test('request body', () => {
test.each(contentTypes)('request body', (contentType) => {
const paths = {
'/api/entities': {
post: {
operationId: 'EntityController_create',
summary: 'Create entity',
requestBody: {
content: {
'application/json': {
[contentType]: {
schema: {
$ref: '#/components/schemas/Entity',
},
Expand Down
4 changes: 2 additions & 2 deletions src/n8n/SchemaToINodeProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class N8NINodeProperties {
fieldSchemaKeys = this.fromSchema(parameter.schema!!);
}
if (!fieldSchemaKeys) {
const regexp = /application\/json.*/
const regexp = /application\/(?:.*\+)?json.*/
const content = findKey(parameter.content, regexp)
fieldSchemaKeys = this.fromSchema(content.schema);
}
Expand Down Expand Up @@ -168,7 +168,7 @@ export class N8NINodeProperties {
return [];
}
body = this.refResolver.resolve<OpenAPIV3.RequestBodyObject>(body)
const regexp = /application\/json.*/
const regexp = /application\/(?:.*\+)?json.*/
const content = findKey(body.content, regexp)
if (!content) {
throw new Error(`No '${regexp}' content found`);
Expand Down