Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create method to get available property names from API #44

Open
sthiepaan opened this issue Oct 3, 2020 · 4 comments
Open

Create method to get available property names from API #44

sthiepaan opened this issue Oct 3, 2020 · 4 comments

Comments

@sthiepaan
Copy link
Collaborator

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!

@jav7zaid
Copy link
Contributor

jav7zaid commented Oct 3, 2020

@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. 👈

@sthiepaan
Copy link
Collaborator Author

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?

@bhatvikrant
Copy link
Owner

Hmm, JSON schema is great, but at the same time we have to look at the bundle size of the library

@sthiepaan
Copy link
Collaborator Author

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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants