Repository: Redocly/openapi-cli (ts)

Issue:
Bundling converts date-time examples to OrderedMap {}


**To Reproduce**
![Screenshot from 2021-11-29 14-27-31](https://user-images.githubusercontent.com/19946948/143837645-591f6800-9043-4f11-9d4d-cce22814b1e8.png)

CMD: `openapi bundle test.yaml -o final_output.yaml`

**Expected behavior**
![ss1](https://user-images.githubusercontent.com/19946948/143838003-13741ec7-6109-403e-bff8-ca62d4db7d84.png)

**Actual Behaviour**
![Screenshot from 2021-11-29 14-31-53](https://user-images.githubusercontent.com/19946948/143838172-74ebf9ae-1942-446e-9dcc-9df26c50ff00.png)

** reason **
post bundling qoutes from the api documentation gets removed..
![Screenshot from 2021-11-29 14-37-15](https://user-images.githubusercontent.com/19946948/143840329-d8ba71dd-9e6e-4364-8013-116e7b11d70e.png)
 

Pull request description:
fix: converts date-time
## What/Why/How?
Closes #461

## Check yourself
- [x] Code is linted
- [ ] Tested with redoc/reference-docs/workflows
- [x] All new/updated code is covered with tests

## Security
- [x] Security impact of change has been considered
- [x] Code follows company security practices and guidelines


Patch:
diff --git a/packages/core/src/js-yaml/index.ts b/packages/core/src/js-yaml/index.ts
index 6d2b0c64..7dff828b 100644
--- a/packages/core/src/js-yaml/index.ts
+++ b/packages/core/src/js-yaml/index.ts
@@ -15,5 +15,4 @@ const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = JSON_SCHEMA.extend({
 export const parseYaml = (str: string, opts?: LoadOptions): unknown =>
   load(str, {schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP, ...opts});
 
-export const stringifyYaml = (obj: any, opts?: DumpOptions): string =>
-  dump(obj, {schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP, ...opts});
+export const stringifyYaml = (obj: any, opts?: DumpOptions): string => dump(obj, opts);


Test patch:
diff --git a/__tests__/bundle/primitive-types/snapshot.js b/__tests__/bundle/primitive-types/snapshot.js
index dd0a0753..ebf73cb7 100644
--- a/__tests__/bundle/primitive-types/snapshot.js
+++ b/__tests__/bundle/primitive-types/snapshot.js
@@ -30,7 +30,7 @@ paths:
                   decimal: 12.34
                   numberWithLeadingZero: 127
                   boolean: true
-                  date: 2020-01-01
+                  date: '2020-01-01'
                   array:
                     - 1
                     - 2
diff --git a/packages/core/src/__tests__/js-yaml.test.ts b/packages/core/src/__tests__/js-yaml.test.ts
index bb0478ee..f06321ee 100644
--- a/packages/core/src/__tests__/js-yaml.test.ts
+++ b/packages/core/src/__tests__/js-yaml.test.ts
@@ -1,3 +1,4 @@
+import { outdent } from 'outdent';
 import { parseYaml, stringifyYaml } from '../js-yaml';
 
 const yaml = `
@@ -7,7 +8,8 @@ const yaml = `
   number: 1000
   decimal: 12.34
   boolean: true
-  date: 2020-01-01
+  dateWithoutQuotes: 2020-01-01
+  dateWithQuotes: '2020-01-01'
   array:
     - 1
     - 2
@@ -16,6 +18,16 @@ const yaml = `
     key2: 2
 `;
 
+const yamlToDump = outdent`
+  date: '2022-01-21T11:29:56.694Z'
+  dateWithoutQuotes: 2020-01-01
+  dateWithQuotes: '2020-01-01'
+  dateImplicit: !!str 2020-01-01
+  string: test
+  stringWithQuotes: 'test'
+  stringWithDoubleQuotes: "test"
+`;
+
 const jsObject = {
   emptyValue: null,
   'spaces in keys': 'spaces in keys',
@@ -23,7 +35,8 @@ const jsObject = {
   number: 1000,
   decimal: 12.34,
   boolean: true,
-  date: '2020-01-01',
+  dateWithoutQuotes: '2020-01-01',
+  dateWithQuotes: '2020-01-01',
   array: [1, 2],
   object: { key1: 1, key2: 2 },
 };
@@ -33,14 +46,25 @@ describe('js-yaml', () => {
     expect(parseYaml(yaml)).toEqual(jsObject);
   });
 
+  test('should correctly dump date and string', () => {
+    expect(stringifyYaml(parseYaml(yamlToDump))).toMatchInlineSnapshot(
+    `
+    "date: '2022-01-21T11:29:56.694Z'
+    dateWithoutQuotes: '2020-01-01'
+    dateWithQuotes: '2020-01-01'
+    dateImplicit: '2020-01-01'
+    string: test
+    stringWithQuotes: test
+    stringWithDoubleQuotes: test
+    "
+    `);
+  });
+
   test('parse and stringify', () => {
     expect(parseYaml(stringifyYaml(jsObject))).toEqual(jsObject);
   });
 
   test('should throw an error for unsupported types', () => {
-    expect(() => stringifyYaml({ date: new Date() }))
-      .toThrow('unacceptable kind of an object to dump [object Date]');
-
     expect(() => stringifyYaml({ foo: () => {} }))
       .toThrow('unacceptable kind of an object to dump [object Function]');
   });