Create method to get available property names from API
As mentioned in #32 we could extend this package with:
- Method that allow API consumers get the names of all properties (so they can build categories tree)
- All countries should contain all categories for that property (even if they don't have a value)
After calling that method what we could receive is:
[ "country", "capital", "currency", "native_language", "famous_for", "phone_code", "flag", "drive_direction"]
Unfortunately, not all of those properties are "useful" for that.
My first idea was to simply grab first item from data and extract its all property names. But I am not 100% sure if this is a clean and proper way to do. Maybe instead we should just define it separately and keep in mind to maintain together with changes to the data model 🤔
Feel free to have an input how can we achieve this!
@sthiepaan I agree, all countries should have these properties to maintain consistency, irrespective of whether data is present for them or not.
I think maintaining separate schema for the properties is a good idea. Later on we can add a test to check the properties of all countries against the schema, such that no countries have properties other that mentioned in the model. 👈
JSON Schema is definitely a a thing to consider. We could use Ajv for that.
Should we care about the usability of some properties? Or just list them all and let user decide if they want to extract some from that list?
Hmm, JSON schema is great, but at the same time we have to look at the bundle size of the library
You are right @bhatvikrant. Less dependencies ➡️ smaller bundle ➡️ the better! If API gets too complicated we might consider using external tools to handle data models easily. But for now, since we do not have multiple abstractions, different datas etc. we could write a test with Jasmine to handle this. Shouldn't be that hard tho 🤔