diff --git a/packages/parsers/src/openapi/3.1/paths/__test__/request/MultipartFormDataPropertySchemaConverter.node.test.ts b/packages/parsers/src/openapi/3.1/paths/__test__/request/MultipartFormDataPropertySchemaConverter.node.test.ts index ce4afc59b1..df25f0f9e1 100644 --- a/packages/parsers/src/openapi/3.1/paths/__test__/request/MultipartFormDataPropertySchemaConverter.node.test.ts +++ b/packages/parsers/src/openapi/3.1/paths/__test__/request/MultipartFormDataPropertySchemaConverter.node.test.ts @@ -123,7 +123,10 @@ describe("MultipartFormDataPropertySchemaConverterNode", () => { const result = converter.convert(); expect(result).toEqual({ type: "alias", - value: { type: "primitive", value: { type: "base64" } }, + value: { + type: "primitive", + value: { type: "base64", mimeType: "image/jpeg" }, + }, }); }); }); diff --git a/packages/parsers/src/openapi/3.1/schemas/primitives/StringConverter.node.ts b/packages/parsers/src/openapi/3.1/schemas/primitives/StringConverter.node.ts index 020b69e47c..280936c78b 100644 --- a/packages/parsers/src/openapi/3.1/schemas/primitives/StringConverter.node.ts +++ b/packages/parsers/src/openapi/3.1/schemas/primitives/StringConverter.node.ts @@ -43,6 +43,7 @@ export class StringConverterNode extends BaseOpenApiV3_1ConverterNodeWithExample minLength: number | undefined; maxLength: number | undefined; enum: EnumConverterNode | undefined; + mimeType: string | undefined; constructor( args: BaseOpenApiV3_1ConverterNodeConstructorArgs @@ -108,6 +109,8 @@ export class StringConverterNode extends BaseOpenApiV3_1ConverterNodeWithExample this.minLength = this.input.minLength; this.maxLength = this.input.maxLength; + this.mimeType = this.input.contentMediaType; + if (this.input.default != null && typeof this.input.default !== "string") { this.context.errors.warning({ message: `Expected default value to be a string. Received ${this.input.default}`, @@ -154,14 +157,21 @@ export class StringConverterNode extends BaseOpenApiV3_1ConverterNodeWithExample type: "alias", value: { type: "primitive", - value: { - type, - format: type === "string" ? this.format : undefined, - regex: this.regex, - minLength: this.minLength, - maxLength: this.maxLength, - default: this.default, - }, + value: + type === "base64" + ? { + type, + mimeType: this.mimeType, + default: this.default, + } + : { + type, + format: type === "string" ? this.format : undefined, + regex: this.regex, + minLength: this.minLength, + maxLength: this.maxLength, + default: this.default, + }, }, }; }