Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
8. Faking Data
Clone this wiki locally
Make Up Data
The following workflow describes how to create a full stack of XapiX resources that are freely combinable with every other XapiX resource. All you need is a google sheet. This is especially useful:
- To Mock Resource Classes that you wish would exist backed with a real team-editable data source
- When you miss entries in an existing data source, create your own one and map them into the same Resource Class
Creating your external Data Source with "Google Sheets"
Sign in to your Google Account and create a "Sheet" in the Sheets app
On very first row enter column headings. Use letters, numbers and underscores only (no whitespaces)!
Use one column as an identifier (ID) column identifying each individual row. In the simplest form they'd just equal the row number of your sheet. Fill the rest of your columns as you like according to the headings row.
On the Sheets menu, select "File" -> "Publish to the Web". On the now open menu unfold "Published content & settings", leave the checkbox "Automatically republish when changes are made" checked and hit the "Start publishing" button. You'll get a confirmation dialog next. On the "Link" tab select Comma-separated-values (.csv) and copy & paste that link somewhere you find it back. If you want to test: Pasting that link in your browser URL field should download that file to your computer.
If you later decide to add more rows or change entries, these changes will propagate all the way to your XapiX endpoint.
Getting your data into XapiX
On your existing XapiX Project Add a Web Interface (Sidebar -> Web Interfaces -> Add)
Enter a "Name", select "Type" -> "csv" and paste the Sheets URL you got at 1.4. into "URL" field. Hit "Create Web Interface" button. You should see a confirmation screen displaying one of your data sets.
Specifying the Output Format in XapiX
On your existing XapiX Project Add a Resource Class (Sidebar -> Resources Classes -> Add)
Enter names. The "resource collection name" shall be the plural form of the "individual resource name". Hit the "Create Resource Class" button.
Visit it's "Dashboard" and within the "Resource Class Attributes and Relationships" section add all attributes according to heading columns in 1.2. Hit the "Save" Button you'll find next to the section's heading.
Select the identifier (ID) column from 1.3. as "Individual resource identifier" and hit "Save" again.
If you'd like your resource's data sets to be filterable by an attribute, click on the "Edit" button next to it. In the following menu you can set it to be filterable. There are further features documented here.
Mapping Data from source Web Interface to Resource Class
On your existing XapiX Project Add a Mapping (Sidebar -> Mappings -> Add)
Select a name, the Web Interfaces and Resource Classes you just created and select "Purpose" -> "Live". Live-Mapping means XapiX triggers a query to Google Sheets source file on each API call, which is slower but this way changes on your Google Sheet instantly propagate through to XapiX API output. Further Read.
Do a 1:1 Mapping by dragging a Web Interface Attribute from the left to the according Resource Class Attribute on the right. Hit the "Create" button. Repeat until all are mapped.
Congrats, you're done!
- Check Resource Class by visiting it's Dashboard. The "Result Based on Mapped Web Interface Data Samples" section should indicate your Mapping succeeded.
- On your Sidebar -> Project Dashboard toggle the "Test Resource Classes" section and click on the link belonging to your Resource Class. The Web CLI should open and display the data sets of your Excel sheet in raw jsonapi.org output format.
Generating Test Data
- go to new Resource Class via sidebar navigation
- create Resource Class
- go to Resource Class dashboard
- add some Resource Class Attributes
- pick Resource Class's individual resource identifier
- set Resource Class Attribute to be filterable if desired
- check Resource Class dashboard
- go to new Resource Class Fake
- create Resource Class Fake
- check Resource Class Fake dashboard
- publish fake data to S3
- generate Web Interface
- generate Mapping
- edit Mapping
- set Mapping purpose to static