Bugzilla – Attachment 175895 Details for
Bug 38503
Add a Cypress task to generate objects based on its swagger def spec
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38503: Do not list the objects
Bug-38503-Do-not-list-the-objects.patch (text/plain), 1.75 KB, created by
Victor Grousset/tuxayo
on 2024-12-22 09:47:26 UTC
(
hide
)
Description:
Bug 38503: Do not list the objects
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-12-22 09:47:26 UTC
Size:
1.75 KB
patch
obsolete
>From 786eaeb7e94a54e26c6c89d0080dc3db103c978a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 4 Dec 2024 14:05:51 +0100 >Subject: [PATCH] Bug 38503: Do not list the objects > >No need to list all the objects, just retrieve the spec depending on the >"object" var we pass. > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > t/cypress/plugins/mockData.js | 17 ++++++----------- > 1 file changed, 6 insertions(+), 11 deletions(-) > >diff --git a/t/cypress/plugins/mockData.js b/t/cypress/plugins/mockData.js >index 0f41eaef2a..6cd20ed108 100644 >--- a/t/cypress/plugins/mockData.js >+++ b/t/cypress/plugins/mockData.js >@@ -1,14 +1,7 @@ > const { faker } = require("@faker-js/faker"); > const { readYamlFile } = require("./../plugins/readYamlFile.js"); >+const fs = require('fs'); > >-const objects = { >- patron: { >- spec: "patron", >- }, >- library: { >- spec: "library", >- }, >-}; > const generateMockData = type => { > if (Array.isArray(type)) { > type = type.filter(t => t != '"null"')[0]; >@@ -50,10 +43,12 @@ const generateDataFromSchema = (properties, values = {}) => { > }; > > const buildSampleObjects = ({ object, values, count = 1 }) => { >- if (!objects.hasOwnProperty(object)) { >- throw new Error(`Object type not supported: ${object}`); >+ const yamlPath = `api/v1/swagger/definitions/${object}.yaml`; >+ if (!fs.existsSync(yamlPath)) { >+ throw new Error( >+ `Object type not supported: '${object}'. No spec file.` >+ ); > } >- const yamlPath = `api/v1/swagger/definitions/${objects[object].spec}.yaml`; > const schema = readYamlFile(yamlPath); > return Array.from({ length: count }, () => > generateDataFromSchema(schema.properties, values) >-- >2.47.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38503
:
174872
|
174873
|
174874
|
174875
|
174876
|
174884
|
174885
|
174921
|
174922
|
175173
|
175175
|
175212
|
175213
|
175214
|
175215
|
175216
|
175217
|
175218
|
175219
|
175220
|
175221
|
175222
|
175888
|
175889
|
175890
|
175891
|
175892
|
175893
|
175894
|
175895
|
175896
|
176073
|
176074
|
176075
|
176076
|
176077
|
176078
|
176079
|
176080
|
176081
|
176775
|
176776
|
176792