Skip to content
Snippets Groups Projects
Commit 1334ef2e authored by lag-of-death's avatar lag-of-death Committed by Alvaro Cabrera Durán
Browse files

fix: return consistent results when generating uuids (#526)

* fix: return consistent results when generating uuids

* chore: generate dist files
parent fa0cfc85
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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'];
......
......@@ -25,6 +25,14 @@
"format": "time"
},
"type": "string"
},
{
"description": "should handle uuid",
"schema": {
"type": "string",
"format": "uuid"
},
"type": "string"
}
]
}
......
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');
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment