Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Of .stringify() and dates/timestamps #119

Closed
nulltoken opened this issue Aug 25, 2019 · 1 comment · Fixed by armand-janssen/openapi-transformer#36 or armand-janssen/openapi-transformer#41
Labels
bug Something isn't working

Comments

@nulltoken
Copy link

nulltoken commented Aug 25, 2019

Hello,

Pasting the following in https://npm.runkit.com/yaml

var yaml=require("yaml")
var opts = {version: '1.1'};

var inObj = {
  canonical: "2001-12-15T02:59:43.1Z",
  validIso8601: "2001-12-14t21:59:43.10-05:00",
  spaceSeparated: "2001-12-14 21:59:43.10 -5",
  noTimeZone: "2001-12-15 2:59:43.10",
  dateUTC: "2002-12-14",
  b: "2012-10-12T12:43:51Z",
  c: "2012-10-12T12:43:51.1",
  int: 1,
  bool: true
};

console.log(inObj)

var a=yaml.stringify(inObj, opts)
console.log(a)

var outObj = yaml.parse(a, opts);
console.log(outObj)

produces the following

image

@eemeli From #117, I thought I understood that specifying version as 1.1 would help disambiguate this and would help me keeping things that look like timestamps in a quoted form.

I may have misunderstood your explanations.

Help? 🙏

References:

@eemeli
Copy link
Owner

eemeli commented Sep 9, 2019

Aah, bother. Sorry for having left this unanswered so long. That's a bug, caused by an incorrect optimisation in the stringifier. The re-parsing test was getting skipped if the string didn't match the regexp ^[\w.+-]+$. That's a valid assumption to make for YAML 1.2, but not for 1.1. I've now left it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants