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

add type json-schemas for all data models #118

Closed
ahdinosaur opened this issue Jul 26, 2017 · 10 comments · Fixed by #124
Closed

add type json-schemas for all data models #118

ahdinosaur opened this issue Jul 26, 2017 · 10 comments · Fixed by #124
Assignees
Labels
Milestone

Comments

@ahdinosaur
Copy link
Member

database models: https://github.com/root-systems/cobuy/wiki/Models

@ahdinosaur
Copy link
Member Author

should we make this a priority for this sprint? @gregorykan @agentlewis

i wonder if it would help better describe the app for on-boarding new devs.

@gregorykan
Copy link
Contributor

@ahdinosaur @agentlewis given we are (abruptly?) in a transition period, with @sarah-arrrgh and @NotThatSmith coming on board, and me heading off, i think it makes sense to prioritize this issue to facilitate onboarding, i.e. for us to straddle the 'present' (what we had planned for this sprint) and also the future (facilitating onboarding)

@gregorykan gregorykan added this to the sprint 3 milestone Jul 26, 2017
@ahdinosaur
Copy link
Member Author

i also recommend we use something like json-schema-faker in our tests and storybooks so our fake test data is always in sync with our schemas.

@danalexilewis
Copy link

I agree - I assume it makes debugging easier?

@danalexilewis danalexilewis modified the milestones: sprint 4, sprint 3 Jul 31, 2017
@danalexilewis
Copy link

ajv for validation - https://github.com/epoberezkin/ajv

@ahdinosaur
Copy link
Member Author

understanding JSON schema: https://spacetelescope.github.io/understanding-json-schema/

@ahdinosaur
Copy link
Member Author

examples:

agent profile

{
  id: 'agents/Profile',
  title: 'Profile',
  type: 'object',
  properties: {
    id: {
      type: 'integer',
      description: 'id referencing profile...'
    },
    agentId: {
      type: 'integer',
      description: 'id referencing agent...'
    },
    name: {
      type: 'string',
      description: 'agent name...'
    },
    description: {
      type: 'string',
      description: 'agent biography...'
    },
    avatar: {
      type: 'string',
      format: 'url',
      description: 'agent avatar image link...'
    }
  }
}

agent with profile

{
  id: 'agents/Agent',
  title: 'Agent',
  type: 'object',
  properties: {
    id: {
      type: 'integer',
      description: 'id referencing agent...'
    },
    profile: {
      $ref: 'agents/Profile'
    }
  }
}

@ahdinosaur
Copy link
Member Author

in general, i think we'll have schemas to represent:

  • database models (as in the wiki page)
  • redux state models (same as database?)
  • getter models (composed from database / redux state models, referencing related models)
  • component models? (specific to each component, best to re-use as much as possible, probably out-of-scope for here)

@michael-smith-nz
Copy link
Member

How do we want to use these schemas? Do we want this for Stories and tests only? Or do we want to validate when running in a debug environment as well? I think Ideally we'd want all three, although I haven't looked into tooling

@ahdinosaur
Copy link
Member Author

How do we want to use these schemas?

on my mind:

  • generating fake data for tests and stories
  • validating server endpoints with feathers validateSchema hook
  • maybe (in development) as React component prop types (there's probably a module for this)
  • maybe (in development) as a redux middleware to validate the state tree on every state change

i'm happy to use it everywhere that feels helpful, then we can sort out how to strip out in production later.

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

Successfully merging a pull request may close this issue.

4 participants