Skip to content

Commit

Permalink
feat: add contributor notes for developers
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeCap08055 committed Oct 24, 2024
1 parent be41bd2 commit 14e82c6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Contributions, issues, and feature requests are welcome!

- [Contributing Guidelines](./CONTRIBUTING.md)
- [Open Issues](https://github.com/ProjectLibertyLabs/gateway/issues)
- [Contributor Notes](./developer-docs/CONTRIBUTOR-NOTES.md)

<p align="right">(<a href="#-table-of-contents">back to top</a>)</p>

Expand Down
29 changes: 29 additions & 0 deletions developer-docs/CONTRIBUTOR-NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# General Notes for Contributors

Collected below are some general notes on coding conventions and other tips for contributors.

## Adding Controllers

When adding a new endpoint controller, be sure to do the following:

- [ ] Include the following decorators on the main controller class:

```typescript
@Controller({ version: 'API-version-number-as-string', path: 'controller-path' })`
@ApiTags(`v${API-version-number}/${controller-path})
```

- [ ] Add the new controller to the `x-tagGroups` Redocly OpenAPI extension in the app's `main.ts:generateSwaggerDoc()` call

## Documenting Endpoints and Payloads

### App Service Endpoints

For actual application endpoints, document the payloads and endpoints with the appropriate `@nestjs/swagger` decorators and JSDoc comments and run `npm run generate:openapi` to update the OpenAPI specs. When doing so, observe the following conventions:

- Avoid using the `@ApiProperty(...)` decorator if possible; instead, just use appropriate types for the DTO classes, include optional `?` indicators, and use a JSDoc comment to specify the description and `@example` properties.
- One notable exception; in order to properly annotate enum types, you must use the `@ApiProperty()` decorator with the `enum` and `enumName` properties.

### Webhook Endpoints

Because the `@nestjs/swagger` package doesn't support extracting documentation for types and paths not attached to a controller in the app, webhook specifications are maintained manually and used to generate types used in the app. Add any updates or new types and paths to the appropriate YAML or JSON file, and run `npm generate:types` to update the generated types in the code.

0 comments on commit 14e82c6

Please sign in to comment.