diff --git a/test/Optimizer.spec.ts b/test/Optimizer.spec.ts index 21f12d31..f9b54bbf 100644 --- a/test/Optimizer.spec.ts +++ b/test/Optimizer.spec.ts @@ -1,9 +1,20 @@ -import { inputJSON, inputYAML, outputJSON, outputYAML } from './fixtures' +import { + inputJSON, + inputYAML, + outputJSON_mATCFalse_mDTCTrue_schemaFalse, + outputYAML_mATCFalse_mDTCTrue_schemaFalse, + outputYAML_mATCTrue_mDTCFalse_schemaFalse, + outputJSON_mATCTrue_mDTCFalse_schemaFalse, + outputYAML_mATCFalse_mDTCTrue_schemaTrue, + outputJSON_mATCFalse_mDTCTrue_schemaTrue, + outputYAML_mATCTrue_mDTCFalse_schemaTrue, + outputJSON_mATCTrue_mDTCFalse_schemaTrue, +} from './fixtures' import { Optimizer } from '../src' import { Output } from '../src/Optimizer' describe('Optimizer', () => { - it('should produce the correct optimized file with YAML input.', async () => { + it('should produce the correct optimized file with YAML input and `{ moveAllToComponents: false, moveDuplicatesToComponents: true }, disableOptimizationFor: { schema: false } }`.', async () => { const optimizer = new Optimizer(inputYAML) await optimizer.getReport() expect( @@ -21,10 +32,10 @@ describe('Optimizer', () => { }, }) .trim() - ).toEqual(outputYAML.trim()) + ).toEqual(outputYAML_mATCFalse_mDTCTrue_schemaFalse.trim()) }) - it('should produce the correct optimized file with JSON input.', async () => { + it('should produce the correct optimized file with JSON input and `{ moveAllToComponents: false, moveDuplicatesToComponents: true }, disableOptimizationFor: { schema: false } }`.', async () => { const optimizer = new Optimizer(inputJSON) await optimizer.getReport() expect( @@ -42,10 +53,10 @@ describe('Optimizer', () => { }, }) .trim() - ).toEqual(outputYAML.trim()) + ).toEqual(outputYAML_mATCFalse_mDTCTrue_schemaFalse.trim()) }) - it('should produce the correct JSON output.', async () => { + it('should produce the correct JSON output and `{ moveAllToComponents: false, moveDuplicatesToComponents: true }, disableOptimizationFor: { schema: false } }`.', async () => { const optimizer = new Optimizer(inputYAML) await optimizer.getReport() expect( @@ -63,6 +74,195 @@ describe('Optimizer', () => { }, }) .trim() - ).toEqual(outputJSON.trim()) + ).toEqual(outputJSON_mATCFalse_mDTCTrue_schemaFalse.trim()) + }) + + it('should produce the correct optimized file with YAML input and `{ moveAllToComponents: true, moveDuplicatesToComponents: false }, disableOptimizationFor: { schema: false } }`.', async () => { + const optimizer = new Optimizer(inputYAML) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.YAML, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: true, + moveDuplicatesToComponents: false, + }, + disableOptimizationFor: { + schema: false, + }, + }) + .trim() + ).toEqual(outputYAML_mATCTrue_mDTCFalse_schemaFalse.trim()) + }) + + it('should produce the correct optimized file with JSON input and `{ moveAllToComponents: true, moveDuplicatesToComponents: false }, disableOptimizationFor: { schema: false } }`.', async () => { + const optimizer = new Optimizer(inputJSON) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.YAML, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: true, + moveDuplicatesToComponents: false, + }, + disableOptimizationFor: { + schema: false, + }, + }) + .trim() + ).toEqual(outputYAML_mATCTrue_mDTCFalse_schemaFalse.trim()) + }) + + it('should produce the correct JSON output and `{ moveAllToComponents: true, moveDuplicatesToComponents: false }, disableOptimizationFor: { schema: false } }`.', async () => { + const optimizer = new Optimizer(inputYAML) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.JSON, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: true, + moveDuplicatesToComponents: false, + }, + disableOptimizationFor: { + schema: false, + }, + }) + .trim() + ).toEqual(outputJSON_mATCTrue_mDTCFalse_schemaFalse.trim()) + }) + + it('should produce the correct optimized file with YAML input and `{ moveAllToComponents: false, moveDuplicatesToComponents: true }, disableOptimizationFor: { schema: true } }`.', async () => { + const optimizer = new Optimizer(inputYAML) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.YAML, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: false, + moveDuplicatesToComponents: true, + }, + disableOptimizationFor: { + schema: true, + }, + }) + .trim() + ).toEqual(outputYAML_mATCFalse_mDTCTrue_schemaTrue.trim()) + }) + + it('should produce the correct optimized file with JSON input and `{ moveAllToComponents: false, moveDuplicatesToComponents: true }, disableOptimizationFor: { schema: true } }`.', async () => { + const optimizer = new Optimizer(inputJSON) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.YAML, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: false, + moveDuplicatesToComponents: true, + }, + disableOptimizationFor: { + schema: true, + }, + }) + .trim() + ).toEqual(outputYAML_mATCFalse_mDTCTrue_schemaTrue.trim()) + }) + + it('should produce the correct JSON output and `{ moveAllToComponents: false, moveDuplicatesToComponents: true }, disableOptimizationFor: { schema: true } }`.', async () => { + const optimizer = new Optimizer(inputYAML) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.JSON, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: false, + moveDuplicatesToComponents: true, + }, + disableOptimizationFor: { + schema: true, + }, + }) + .trim() + ).toEqual(outputJSON_mATCFalse_mDTCTrue_schemaTrue.trim()) + }) + + it('should produce the correct optimized file with YAML input and `{ moveAllToComponents: true, moveDuplicatesToComponents: false }, disableOptimizationFor: { schema: true } }`.', async () => { + const optimizer = new Optimizer(inputYAML) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.YAML, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: true, + moveDuplicatesToComponents: false, + }, + disableOptimizationFor: { + schema: true, + }, + }) + .trim() + ).toEqual(outputYAML_mATCTrue_mDTCFalse_schemaTrue.trim()) + }) + + it('should produce the correct optimized file with JSON input and `{ moveAllToComponents: true, moveDuplicatesToComponents: false }, disableOptimizationFor: { schema: true } }`.', async () => { + const optimizer = new Optimizer(inputJSON) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.YAML, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: true, + moveDuplicatesToComponents: false, + }, + disableOptimizationFor: { + schema: true, + }, + }) + .trim() + ).toEqual(outputYAML_mATCTrue_mDTCFalse_schemaTrue.trim()) + }) + + it('should produce the correct JSON output and `{ moveAllToComponents: true, moveDuplicatesToComponents: false }, disableOptimizationFor: { schema: true } }`.', async () => { + const optimizer = new Optimizer(inputYAML) + await optimizer.getReport() + expect( + optimizer + .getOptimizedDocument({ + output: Output.JSON, + rules: { + reuseComponents: true, + removeComponents: true, + moveAllToComponents: true, + moveDuplicatesToComponents: false, + }, + disableOptimizationFor: { + schema: true, + }, + }) + .trim() + ).toEqual(outputJSON_mATCTrue_mDTCFalse_schemaTrue.trim()) }) }) diff --git a/test/fixtures.ts b/test/fixtures.ts index 6b5f925f..71387d6c 100644 --- a/test/fixtures.ts +++ b/test/fixtures.ts @@ -164,7 +164,7 @@ components: format: email description: Email of the user` -export const outputYAML = `asyncapi: 3.0.0 +export const outputYAML_mATCFalse_mDTCTrue_schemaFalse = `asyncapi: 3.0.0 info: title: Untidy AsyncAPI file version: 1.0.0 @@ -252,7 +252,10 @@ export const inputJSON = `{ "address": "user/signedup", "messages": { "duped1": { - "$ref": "#/components/messages/duped1" + "payload": { + "type": "object", + "description": "I am duplicated" + } } } }, @@ -260,7 +263,10 @@ export const inputJSON = `{ "address": "user/signedup", "messages": { "duped2": { - "$ref": "#/components/messages/duped1" + "payload": { + "type": "object", + "description": "I am duplicated" + } } } }, @@ -269,16 +275,27 @@ export const inputJSON = `{ "messages": { "canBeReused": { "payload": { - "$ref": "#/components/schemas/canBeReused" + "type": "object", + "description": "I can be reused." } } } }, "UserSignedUp1": { - "$ref": "#/components/channels/UserSignedUp1" + "address": "user/signedup", + "messages": { + "myMessage": { + "$ref": "#/components/messages/UserSignedUp" + } + } }, "UserSignedUp2": { - "$ref": "#/components/channels/UserSignedUp1" + "address": "user/signedup", + "messages": { + "myMessage": { + "$ref": "#/components/messages/UserSignedUp" + } + } }, "deleteAccount": { "address": "user/deleteAccount", @@ -303,17 +320,28 @@ export const inputJSON = `{ } }, "components": { + "channels": { + "unUsedChannel": { + "address": "user/unused", + "messages": { + "myMessage": { + "$ref": "#/components/messages/UserSignedUp" + } + } + } + }, "schemas": { "canBeReused": { "type": "object", "description": "I can be reused." - }, - "payload": { - "type": "object", - "description": "I am duplicated" } }, "messages": { + "unUsedMessage": { + "payload": { + "type": "boolean" + } + }, "DeleteUser": { "payload": { "type": "string", @@ -335,25 +363,293 @@ export const inputJSON = `{ } } } - }, - "duped1": { - "payload": { - "$ref": "#/components/schemas/payload" - } - } - }, - "channels": { - "UserSignedUp1": { - "address": "user/signedup", - "messages": { - "myMessage": { - "$ref": "#/components/messages/UserSignedUp" - } - } } } } }` // eslint-disable-next-line quotes -export const outputJSON = `{"asyncapi":"3.0.0","info":{"title":"Untidy AsyncAPI file","version":"1.0.0","description":"This file contains duplicate and unused messages across the file and is used to test the optimizer."},"channels":{"withDuplicatedMessage1":{"x-origin":"./messages.yaml#/withDuplicatedMessage1FromXOrigin","address":"user/signedup","messages":{"duped1":{"$ref":"#/components/messages/duped1"}}},"withDuplicatedMessage2":{"address":"user/signedup","messages":{"duped2":{"$ref":"#/components/messages/duped1"}}},"withFullFormMessage":{"address":"user/signedup","messages":{"canBeReused":{"payload":{"$ref":"#/components/schemas/canBeReused"}}}},"UserSignedUp1":{"$ref":"#/components/channels/UserSignedUp1"},"UserSignedUp2":{"$ref":"#/components/channels/UserSignedUp1"},"deleteAccount":{"address":"user/deleteAccount","messages":{"deleteUser":{"$ref":"#/components/messages/DeleteUser"}}}},"operations":{"user/deleteAccount.subscribe":{"action":"send","channel":{"$ref":"#/channels/deleteAccount"},"messages":[{"$ref":"#/channels/deleteAccount/messages/deleteUser"}]}},"components":{"schemas":{"canBeReused":{"type":"object","description":"I can be reused."},"payload":{"type":"object","description":"I am duplicated"}},"messages":{"DeleteUser":{"payload":{"type":"string","description":"userId of the user that is going to be deleted"}},"UserSignedUp":{"payload":{"type":"object","properties":{"displayName":{"type":"string","description":"Name of the user"},"email":{"type":"string","format":"email","description":"Email of the user"}}}},"duped1":{"payload":{"$ref":"#/components/schemas/payload"}}},"channels":{"UserSignedUp1":{"address":"user/signedup","messages":{"myMessage":{"$ref":"#/components/messages/UserSignedUp"}}}}}}` +export const outputJSON_mATCFalse_mDTCTrue_schemaFalse = `{"asyncapi":"3.0.0","info":{"title":"Untidy AsyncAPI file","version":"1.0.0","description":"This file contains duplicate and unused messages across the file and is used to test the optimizer."},"channels":{"withDuplicatedMessage1":{"x-origin":"./messages.yaml#/withDuplicatedMessage1FromXOrigin","address":"user/signedup","messages":{"duped1":{"$ref":"#/components/messages/duped1"}}},"withDuplicatedMessage2":{"address":"user/signedup","messages":{"duped2":{"$ref":"#/components/messages/duped1"}}},"withFullFormMessage":{"address":"user/signedup","messages":{"canBeReused":{"payload":{"$ref":"#/components/schemas/canBeReused"}}}},"UserSignedUp1":{"$ref":"#/components/channels/UserSignedUp1"},"UserSignedUp2":{"$ref":"#/components/channels/UserSignedUp1"},"deleteAccount":{"address":"user/deleteAccount","messages":{"deleteUser":{"$ref":"#/components/messages/DeleteUser"}}}},"operations":{"user/deleteAccount.subscribe":{"action":"send","channel":{"$ref":"#/channels/deleteAccount"},"messages":[{"$ref":"#/channels/deleteAccount/messages/deleteUser"}]}},"components":{"schemas":{"canBeReused":{"type":"object","description":"I can be reused."},"payload":{"type":"object","description":"I am duplicated"}},"messages":{"DeleteUser":{"payload":{"type":"string","description":"userId of the user that is going to be deleted"}},"UserSignedUp":{"payload":{"type":"object","properties":{"displayName":{"type":"string","description":"Name of the user"},"email":{"type":"string","format":"email","description":"Email of the user"}}}},"duped1":{"payload":{"$ref":"#/components/schemas/payload"}}},"channels":{"UserSignedUp1":{"address":"user/signedup","messages":{"myMessage":{"$ref":"#/components/messages/UserSignedUp"}}}}}}` + +export const outputYAML_mATCTrue_mDTCFalse_schemaFalse = `asyncapi: 3.0.0 +info: + title: Untidy AsyncAPI file + version: 1.0.0 + description: >- + This file contains duplicate and unused messages across the file and is used + to test the optimizer. +channels: + withDuplicatedMessage1: + $ref: '#/components/channels/withDuplicatedMessage1FromXOrigin' + withDuplicatedMessage2: + $ref: '#/components/channels/withDuplicatedMessage2' + withFullFormMessage: + $ref: '#/components/channels/withFullFormMessage' + UserSignedUp1: + $ref: '#/components/channels/UserSignedUp1' + UserSignedUp2: + $ref: '#/components/channels/UserSignedUp2' + deleteAccount: + $ref: '#/components/channels/deleteAccount' +operations: + user/deleteAccount.subscribe: + action: send + channel: + $ref: '#/channels/deleteAccount' + messages: + - $ref: '#/channels/deleteAccount/messages/deleteUser' + user/deleteAccount: + subscribe: + $ref: '#/components/operations/subscribe' +components: + schemas: + canBeReused: + type: object + description: I can be reused. + payload: + type: object + description: I am duplicated + messages: + DeleteUser: + payload: + type: string + description: userId of the user that is going to be deleted + UserSignedUp: + payload: + type: object + properties: + displayName: + type: string + description: Name of the user + email: + type: string + format: email + description: Email of the user + canBeReused: + payload: + $ref: '#/components/schemas/canBeReused' + duped1: + payload: + $ref: '#/components/schemas/payload' + duped2: + payload: + $ref: '#/components/schemas/payload' + operations: {} + channels: + withDuplicatedMessage1FromXOrigin: + x-origin: ./messages.yaml#/withDuplicatedMessage1FromXOrigin + address: user/signedup + messages: + duped1: + $ref: '#/components/messages/duped1' + withDuplicatedMessage2: + address: user/signedup + messages: + duped2: + $ref: '#/components/messages/duped2' + withFullFormMessage: + address: user/signedup + messages: + canBeReused: + $ref: '#/components/messages/canBeReused' + UserSignedUp1: + address: user/signedup + messages: + myMessage: + $ref: '#/components/messages/UserSignedUp' + payload: + properties: + displayName: + $ref: '#/components/schemas/displayName' + email: + $ref: '#/components/schemas/email' + UserSignedUp2: + address: user/signedup + messages: + myMessage: + $ref: '#/components/messages/UserSignedUp' + deleteAccount: + address: user/deleteAccount + messages: + deleteUser: + $ref: '#/components/messages/DeleteUser'` + +// eslint-disable-next-line quotes +export const outputJSON_mATCTrue_mDTCFalse_schemaFalse = `{"asyncapi":"3.0.0","info":{"title":"Untidy AsyncAPI file","version":"1.0.0","description":"This file contains duplicate and unused messages across the file and is used to test the optimizer."},"channels":{"withDuplicatedMessage1":{"$ref":"#/components/channels/withDuplicatedMessage1FromXOrigin"},"withDuplicatedMessage2":{"$ref":"#/components/channels/withDuplicatedMessage2"},"withFullFormMessage":{"$ref":"#/components/channels/withFullFormMessage"},"UserSignedUp1":{"$ref":"#/components/channels/UserSignedUp1"},"UserSignedUp2":{"$ref":"#/components/channels/UserSignedUp2"},"deleteAccount":{"$ref":"#/components/channels/deleteAccount"}},"operations":{"user/deleteAccount.subscribe":{"action":"send","channel":{"$ref":"#/channels/deleteAccount"},"messages":[{"$ref":"#/channels/deleteAccount/messages/deleteUser"}]},"user/deleteAccount":{"subscribe":{"$ref":"#/components/operations/subscribe"}}},"components":{"schemas":{"canBeReused":{"type":"object","description":"I can be reused."},"payload":{"type":"object","description":"I am duplicated"}},"messages":{"DeleteUser":{"payload":{"type":"string","description":"userId of the user that is going to be deleted"}},"UserSignedUp":{"payload":{"type":"object","properties":{"displayName":{"type":"string","description":"Name of the user"},"email":{"type":"string","format":"email","description":"Email of the user"}}}},"canBeReused":{"payload":{"$ref":"#/components/schemas/canBeReused"}},"duped1":{"payload":{"$ref":"#/components/schemas/payload"}},"duped2":{"payload":{"$ref":"#/components/schemas/payload"}}},"operations":{},"channels":{"withDuplicatedMessage1FromXOrigin":{"x-origin":"./messages.yaml#/withDuplicatedMessage1FromXOrigin","address":"user/signedup","messages":{"duped1":{"$ref":"#/components/messages/duped1"}}},"withDuplicatedMessage2":{"address":"user/signedup","messages":{"duped2":{"$ref":"#/components/messages/duped2"}}},"withFullFormMessage":{"address":"user/signedup","messages":{"canBeReused":{"$ref":"#/components/messages/canBeReused"}}},"UserSignedUp1":{"address":"user/signedup","messages":{"myMessage":{"$ref":"#/components/messages/UserSignedUp","payload":{"properties":{"displayName":{"$ref":"#/components/schemas/displayName"},"email":{"$ref":"#/components/schemas/email"}}}}}},"UserSignedUp2":{"address":"user/signedup","messages":{"myMessage":{"$ref":"#/components/messages/UserSignedUp"}}},"deleteAccount":{"address":"user/deleteAccount","messages":{"deleteUser":{"$ref":"#/components/messages/DeleteUser"}}}}}}` + +export const outputYAML_mATCFalse_mDTCTrue_schemaTrue = `asyncapi: 3.0.0 +info: + title: Untidy AsyncAPI file + version: 1.0.0 + description: >- + This file contains duplicate and unused messages across the file and is used + to test the optimizer. +channels: + withDuplicatedMessage1: + x-origin: ./messages.yaml#/withDuplicatedMessage1FromXOrigin + address: user/signedup + messages: + duped1: + $ref: '#/components/messages/duped1' + withDuplicatedMessage2: + address: user/signedup + messages: + duped2: + $ref: '#/components/messages/duped1' + withFullFormMessage: + address: user/signedup + messages: + canBeReused: + payload: + type: object + description: I can be reused. + UserSignedUp1: + $ref: '#/components/channels/UserSignedUp1' + UserSignedUp2: + $ref: '#/components/channels/UserSignedUp1' + deleteAccount: + address: user/deleteAccount + messages: + deleteUser: + $ref: '#/components/messages/DeleteUser' +operations: + user/deleteAccount.subscribe: + action: send + channel: + $ref: '#/channels/deleteAccount' + messages: + - $ref: '#/channels/deleteAccount/messages/deleteUser' +components: + schemas: + canBeReused: + type: object + description: I can be reused. + messages: + DeleteUser: + payload: + type: string + description: userId of the user that is going to be deleted + UserSignedUp: + payload: + type: object + properties: + displayName: + type: string + description: Name of the user + email: + type: string + format: email + description: Email of the user + duped1: + payload: + type: object + description: I am duplicated + channels: + UserSignedUp1: + address: user/signedup + messages: + myMessage: + $ref: '#/components/messages/UserSignedUp'` + +// eslint-disable-next-line quotes +export const outputJSON_mATCFalse_mDTCTrue_schemaTrue = `{"asyncapi":"3.0.0","info":{"title":"Untidy AsyncAPI file","version":"1.0.0","description":"This file contains duplicate and unused messages across the file and is used to test the optimizer."},"channels":{"withDuplicatedMessage1":{"x-origin":"./messages.yaml#/withDuplicatedMessage1FromXOrigin","address":"user/signedup","messages":{"duped1":{"$ref":"#/components/messages/duped1"}}},"withDuplicatedMessage2":{"address":"user/signedup","messages":{"duped2":{"$ref":"#/components/messages/duped1"}}},"withFullFormMessage":{"address":"user/signedup","messages":{"canBeReused":{"payload":{"type":"object","description":"I can be reused."}}}},"UserSignedUp1":{"$ref":"#/components/channels/UserSignedUp1"},"UserSignedUp2":{"$ref":"#/components/channels/UserSignedUp1"},"deleteAccount":{"address":"user/deleteAccount","messages":{"deleteUser":{"$ref":"#/components/messages/DeleteUser"}}}},"operations":{"user/deleteAccount.subscribe":{"action":"send","channel":{"$ref":"#/channels/deleteAccount"},"messages":[{"$ref":"#/channels/deleteAccount/messages/deleteUser"}]}},"components":{"schemas":{"canBeReused":{"type":"object","description":"I can be reused."}},"messages":{"DeleteUser":{"payload":{"type":"string","description":"userId of the user that is going to be deleted"}},"UserSignedUp":{"payload":{"type":"object","properties":{"displayName":{"type":"string","description":"Name of the user"},"email":{"type":"string","format":"email","description":"Email of the user"}}}},"duped1":{"payload":{"type":"object","description":"I am duplicated"}}},"channels":{"UserSignedUp1":{"address":"user/signedup","messages":{"myMessage":{"$ref":"#/components/messages/UserSignedUp"}}}}}}` + +export const outputYAML_mATCTrue_mDTCFalse_schemaTrue = `asyncapi: 3.0.0 +info: + title: Untidy AsyncAPI file + version: 1.0.0 + description: >- + This file contains duplicate and unused messages across the file and is used + to test the optimizer. +channels: + withDuplicatedMessage1: + $ref: '#/components/channels/withDuplicatedMessage1FromXOrigin' + withDuplicatedMessage2: + $ref: '#/components/channels/withDuplicatedMessage2' + withFullFormMessage: + $ref: '#/components/channels/withFullFormMessage' + UserSignedUp1: + $ref: '#/components/channels/UserSignedUp1' + UserSignedUp2: + $ref: '#/components/channels/UserSignedUp2' + deleteAccount: + $ref: '#/components/channels/deleteAccount' +operations: + user/deleteAccount.subscribe: + action: send + channel: + $ref: '#/channels/deleteAccount' + messages: + - $ref: '#/channels/deleteAccount/messages/deleteUser' + user/deleteAccount: + subscribe: + $ref: '#/components/operations/subscribe' +components: + schemas: + canBeReused: + type: object + description: I can be reused. + messages: + DeleteUser: + payload: + type: string + description: userId of the user that is going to be deleted + UserSignedUp: + payload: + type: object + properties: + displayName: + type: string + description: Name of the user + email: + type: string + format: email + description: Email of the user + canBeReused: + payload: + type: object + description: I can be reused. + duped1: + payload: + type: object + description: I am duplicated + duped2: + payload: + type: object + description: I am duplicated + operations: {} + channels: + withDuplicatedMessage1FromXOrigin: + x-origin: ./messages.yaml#/withDuplicatedMessage1FromXOrigin + address: user/signedup + messages: + duped1: + $ref: '#/components/messages/duped1' + withDuplicatedMessage2: + address: user/signedup + messages: + duped2: + $ref: '#/components/messages/duped2' + withFullFormMessage: + address: user/signedup + messages: + canBeReused: + $ref: '#/components/messages/canBeReused' + UserSignedUp1: + address: user/signedup + messages: + myMessage: + $ref: '#/components/messages/UserSignedUp' + UserSignedUp2: + address: user/signedup + messages: + myMessage: + $ref: '#/components/messages/UserSignedUp' + deleteAccount: + address: user/deleteAccount + messages: + deleteUser: + $ref: '#/components/messages/DeleteUser'` + +// eslint-disable-next-line quotes +export const outputJSON_mATCTrue_mDTCFalse_schemaTrue = `{"asyncapi":"3.0.0","info":{"title":"Untidy AsyncAPI file","version":"1.0.0","description":"This file contains duplicate and unused messages across the file and is used to test the optimizer."},"channels":{"withDuplicatedMessage1":{"$ref":"#/components/channels/withDuplicatedMessage1FromXOrigin"},"withDuplicatedMessage2":{"$ref":"#/components/channels/withDuplicatedMessage2"},"withFullFormMessage":{"$ref":"#/components/channels/withFullFormMessage"},"UserSignedUp1":{"$ref":"#/components/channels/UserSignedUp1"},"UserSignedUp2":{"$ref":"#/components/channels/UserSignedUp2"},"deleteAccount":{"$ref":"#/components/channels/deleteAccount"}},"operations":{"user/deleteAccount.subscribe":{"action":"send","channel":{"$ref":"#/channels/deleteAccount"},"messages":[{"$ref":"#/channels/deleteAccount/messages/deleteUser"}]},"user/deleteAccount":{"subscribe":{"$ref":"#/components/operations/subscribe"}}},"components":{"schemas":{"canBeReused":{"type":"object","description":"I can be reused."}},"messages":{"DeleteUser":{"payload":{"type":"string","description":"userId of the user that is going to be deleted"}},"UserSignedUp":{"payload":{"type":"object","properties":{"displayName":{"type":"string","description":"Name of the user"},"email":{"type":"string","format":"email","description":"Email of the user"}}}},"canBeReused":{"payload":{"type":"object","description":"I can be reused."}},"duped1":{"payload":{"type":"object","description":"I am duplicated"}},"duped2":{"payload":{"type":"object","description":"I am duplicated"}}},"operations":{},"channels":{"withDuplicatedMessage1FromXOrigin":{"x-origin":"./messages.yaml#/withDuplicatedMessage1FromXOrigin","address":"user/signedup","messages":{"duped1":{"$ref":"#/components/messages/duped1"}}},"withDuplicatedMessage2":{"address":"user/signedup","messages":{"duped2":{"$ref":"#/components/messages/duped2"}}},"withFullFormMessage":{"address":"user/signedup","messages":{"canBeReused":{"$ref":"#/components/messages/canBeReused"}}},"UserSignedUp1":{"address":"user/signedup","messages":{"myMessage":{"$ref":"#/components/messages/UserSignedUp"}}},"UserSignedUp2":{"address":"user/signedup","messages":{"myMessage":{"$ref":"#/components/messages/UserSignedUp"}}},"deleteAccount":{"address":"user/deleteAccount","messages":{"deleteUser":{"$ref":"#/components/messages/DeleteUser"}}}}}}`