From 1334ef2ea0297d606ac202aa8b52855a9dde2fd6 Mon Sep 17 00:00:00 2001
From: lag-of-death <mateuszwit21@gmail.com>
Date: Tue, 1 Oct 2019 14:46:02 +0200
Subject: [PATCH] fix: return consistent results when generating uuids (#526)

* fix: return consistent results when generating uuids

* chore: generate dist files
---
 dist/bundle.umd.min.js                   | Bin 222264 -> 222249 bytes
 dist/index.esm.js                        | Bin 49258 -> 49243 bytes
 dist/index.js                            | Bin 49460 -> 49445 bytes
 dist/index.umd.js                        | Bin 76324 -> 76309 bytes
 dist/index.umd.min.js                    | Bin 28949 -> 28934 bytes
 dist/index.umd.min.js.map                | Bin 113202 -> 113187 bytes
 src/generators/coreFormat.js             |   2 +-
 tests/schema/core/formats.json           |   8 ++++++++
 tests/unit/generators/coreFormat.spec.js |  16 ++++++++++++++++
 9 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 tests/unit/generators/coreFormat.spec.js

diff --git a/dist/bundle.umd.min.js b/dist/bundle.umd.min.js
index c4d89ff3a7ee3bb434b35695297d2062d700f8f2..5d71ca4888665c4062b0a8747a6af526d494e750 100644
GIT binary patch
delta 28
kcmdmSf_LQ!-i8*&EljSTnT!m!yMJc-;JMw+midz!0J7){<NyEw

delta 44
zcmZ2^f_KLW-i8*&EljSTnG7wryMJc-;K?7SVQ*DhlxJ01nwesyX}{gvmidz!0Fs>$
A(*OVf

diff --git a/dist/index.esm.js b/dist/index.esm.js
index 8aab5fe752f920ca0742812513a3e717930ea9af..966ade9ba3a25ae099a2a8f92167c58177a78d6e 100644
GIT binary patch
delta 14
VcmaFWz<j%bd4qrN=D1!SV*oSa1~mWx

delta 30
lcmccJ!2GI#d4qp1f1HNBRcTS4RcUEvij}7QX8&FuV*t8J3mgCd

diff --git a/dist/index.js b/dist/index.js
index 8d05375d63a343539b2121754898e26149998a1a..251ab3cd00e9268a98634057fdd2b04ed7e267b9 100644
GIT binary patch
delta 14
Vcmdne#JseLdBfk{%{+Y?#sD&Z21Wn?

delta 30
lcmZ45#Jr`6dBfjc{x}VLtJ0!8tJ2cU6e~^p&3}6}i~+$!3@iWu

diff --git a/dist/index.umd.js b/dist/index.umd.js
index 149b6ef75ff23c141d7f6662e404953cd9e39e99..b9e90303f59d071321c7f63ab4e132823898ef46 100644
GIT binary patch
delta 20
ccmZ2-g=Oj$mI+EsMg|*Ix<7B;_c_fB09`8yQvd(}

delta 36
scmbPwg=NVVmI+EshL#&ux<B*BY1mtp7Ufx$mS(0{Y1(gI|2fSJ00bcpLI3~&

diff --git a/dist/index.umd.min.js b/dist/index.umd.min.js
index ea5aa55bdb7ffe8b9724f3931df524e9d9a0fcec..1766def64ae4bb2e9ec8d354d78b3f4f3a2f56d7 100644
GIT binary patch
delta 20
ccmbRGh_USv;{+upBZG}9A3QfJdwo&^09Wq_J^%m!

delta 36
scmZpB#5na4;{+upL(7dSA3XWvH0-TPi}I{WOEXifH0?Kwczsd>0Qv?EEdT%j

diff --git a/dist/index.umd.min.js.map b/dist/index.umd.min.js.map
index cd29ca7a5e9c53f9c491b3f1538f9f60bb7d465d..c33f69cb5f57837d4902d0b6333d5462dea99960 100644
GIT binary patch
delta 22
ecmdn=g>CT{whh*gHhVpiUB#HbJ)?*5lr8{<)(Xe~

delta 38
ucmZ4dg>BOpwhh*g_~SI}txAjXtV&BWQ>--YH(NiFUB#%qJ+g=Klr8{1h7V)_

diff --git a/src/generators/coreFormat.js b/src/generators/coreFormat.js
index 4ffccc84..5d5003c8 100644
--- a/src/generators/coreFormat.js
+++ b/src/generators/coreFormat.js
@@ -21,7 +21,7 @@ const regexps = {
   'json-pointer': `(/(?:${FRAGMENT.replace(']*', '/]*')}|~[01]))+`,
 
   // some types from https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#data-types (?)
-  uuid: '^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$',
+  uuid: '[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$',
 };
 
 regexps.iri = regexps['uri-reference'];
diff --git a/tests/schema/core/formats.json b/tests/schema/core/formats.json
index 462080be..a3d80072 100644
--- a/tests/schema/core/formats.json
+++ b/tests/schema/core/formats.json
@@ -25,6 +25,14 @@
           "format": "time"
         },
         "type": "string"
+      },
+      {
+        "description": "should handle uuid",
+        "schema": {
+          "type": "string",
+          "format": "uuid"
+        },
+        "type": "string"
       }
     ]
   }
diff --git a/tests/unit/generators/coreFormat.spec.js b/tests/unit/generators/coreFormat.spec.js
new file mode 100644
index 00000000..26dd7d52
--- /dev/null
+++ b/tests/unit/generators/coreFormat.spec.js
@@ -0,0 +1,16 @@
+import { expect } from 'chai';
+import coreFormatGenerator from '../../../src/generators/coreFormat';
+
+/* global describe, it */
+
+describe('coreFormat Generator', () => {
+  describe('uuid', () => {
+    it('should always match uuid regex', () => {
+      expect(coreFormatGenerator('uuid')).to.match(/[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/);
+    });
+
+    it('should not be presented in the form of UUID as a URN', () => {
+      expect(coreFormatGenerator('uuid')).to.not.include('urn:uuid');
+    });
+  });
+});
-- 
GitLab