fix: leave multiline strings in literal mode (#822)

This commit is contained in:
Ivan Osypov
2022-08-23 11:59:21 +03:00
committed by GitHub
parent 4b3b0d827d
commit 06c9e392e4
6 changed files with 84 additions and 4 deletions

View File

@@ -0,0 +1,3 @@
apis:
main:
root: ./test.yaml

View File

@@ -0,0 +1,54 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle bundle-description-long 1`] = `
openapi: 3.1.0
info:
version: 1.0.0
title: Example.com
termsOfService: https://example.com/terms/
contact:
email: contact@example.com
url: http://example.com/contact
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
description: |
first line loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
second line exists
components: {}
No configurations were defined in extends -- using built in recommended configuration by default.
Warning! This default behavior is going to be deprecated soon.
test.yaml:
1:1 error no-empty-servers Servers must be present.
❌ Validation failed with 1 error.
run \`openapi lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./test.yaml...
📦 Created a bundle for ./test.yaml at stdout <test>ms.
`;
exports[`E2E bundle with long description description should not be in folded mode 1`] = `
openapi: 3.1.0
info:
version: 1.0.0
title: Example.com
termsOfService: https://example.com/terms/
contact:
email: contact@example.com
url: http://example.com/contact
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
description: |
first line loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
second line exists
components: {}
bundling test.yaml...
📦 Created a bundle for test.yaml at stdout <test>ms.
`;

View File

@@ -0,0 +1,15 @@
openapi: 3.1.0
info:
version: 1.0.0
title: Example.com
termsOfService: https://example.com/terms/
contact:
email: contact@example.com
url: http://example.com/contact
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
description: |
first line loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
second line exists
components: {}

View File

@@ -31,10 +31,8 @@ tags:
<SchemaDefinition schemaRef="#/components/schemas/Pet" /> <SchemaDefinition schemaRef="#/components/schemas/Pet" />
- name: store_model - name: store_model
x-displayName: The Order Model x-displayName: The Order Model
description: > description: |
<SchemaDefinition schemaRef="#/components/schemas/Order" <SchemaDefinition schemaRef="#/components/schemas/Order" exampleRef="#/components/examples/Order" showReadOnly={true} showWriteOnly={true} />
exampleRef="#/components/examples/Order" showReadOnly={true}
showWriteOnly={true} />
paths: paths:
/pet/findByStatus: /pet/findByStatus:
get: get:

View File

@@ -229,6 +229,15 @@ describe('E2E', () => {
'--dereferenced', '--dereferenced',
]); ]);
const result = getCommandOutput(args, folderPath);
(<any>expect(result)).toMatchSpecificSnapshot(join(folderPath, 'snapshot.js'));
});
});
describe('bundle with long description', () => {
it('description should not be in folded mode', () => {
const folderPath = join(__dirname, `bundle/bundle-description-long`);
const args = getParams('../../../packages/cli/src/index.ts', 'bundle', ['test.yaml']);
const result = getCommandOutput(args, folderPath); const result = getCommandOutput(args, folderPath);
(<any>expect(result)).toMatchSpecificSnapshot(join(folderPath, 'snapshot.js')); (<any>expect(result)).toMatchSpecificSnapshot(join(folderPath, 'snapshot.js'));
}); });

View File

@@ -107,6 +107,7 @@ export function dumpBundle(obj: any, format: BundleOutputFormat, dereference?: b
} else { } else {
return stringifyYaml(obj, { return stringifyYaml(obj, {
noRefs: !dereference, noRefs: !dereference,
lineWidth: -1,
}); });
} }
} }