HospitalRun / hospitalrun

Monorepo that holds all of HospitalRun's v2 projects.
https://hospitalrun.io
MIT License
926 stars 343 forks source link

OpenAPI/Swagger #15

Open PhearZero opened 5 years ago

PhearZero commented 5 years ago

πŸš€ Feature Proposal

Introduce a Single Source of Truth between all modules via Swagger/OpenAPI and JSON Schema specification

Motivation

Open Closed and Substitution Principles. All packages must share common interfaces in order to ensure API compatibility for internal/external projects. We can EYODF by providing a shared interface #12 that is generated via a standard specification. This way each module can extend | override from the base model | service in order to preform module requirements.

Possible Generators:

OpenAPI Isomorphic Models

Generated to ./packages/core/model

// In Component
import {User} from '@hospitalrun-org/core'
export default class MyComponent<User> {}

OpenAPI Isomorphic Services

Generated to ./packages/core/services

// Consume Service
import {UserService} from '@hospitalrun-org/core'
let user = UserService.operationId({...})

Fastify Decorators and Routes

Generated to ./packages/server/(plugins & services)


// Generates Decorators that look similar to:
import {UserService} from '@hospitalrun-org/core'
fastify.decorate(operationId, UserService.operationId)

// All route based services look similar to: import {User} from '@hospitalrun-org/core' fastify.post('/users', (request,reply)=> {reply.send( fastify.operationId(instanceof User))} )

### React Router with Store integration
> Generated to ./packages/frontend/(tabs || pages)

// Example component import {UserService, User} from '@hospitalrun-org/core' import * as React from 'react' export default class UserPage extends React.Component { render(){

} } // Example Router import UserPage from './pages/UserPage' const routes = [ { path: '/user', exact: true, component: UserPage, } ] export default routes ``` # Blocking Issues: - [X] ~~Fastify CLI Application HospitalRun/hospitalrun-server#152~~ - [X] ~~React Create Application HospitalRun/hospitalrun-frontend#1619~~ - [ ] OpenAPI Core Specification - [ ] Fastify Codegen Template - [ ] Core Codgen Template
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.