Skip to content

Commit

Permalink
[Issue #31] Update repo with working title (#47)
Browse files Browse the repository at this point in the history
* refactor: Updates TypeSpec library to use CommonGrants
* refactor: Updates custom API example to use CommonGrants
* docs: Updates and expands READMEs
  • Loading branch information
widal001 authored Jan 21, 2025
1 parent 2db7378 commit 2841612
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 116 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Simpler grant protocol
# CommonGrants protocol

A common standard for sharing data about grant opportunities, applications, and awards.
An open standard for sharing data about funding opportunities, applications, and awards across the grants ecosystem.

## Key resources

Expand All @@ -9,3 +9,5 @@ A common standard for sharing data about grant opportunities, applications, and
- [Protocol website](https://hhs.github.io/simpler-grants-protocol/)
- [`website/` codebase](website): The code for our public website and docs.
- [Specification](specs): TypeSpec library for the CommonGrants specification.
- [Examples](examples): Example projects that adopt or extend the CommonGrants protocol.
7 changes: 7 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CommonGrants examples

A directory of sample projects that demonstrate how to implement and extend the CommonGrants protocol.

## Example projects

- [Custom API](custom-api): Demonstrates a simple example of an API spec that extends the base CommonGrants protocol.
10 changes: 5 additions & 5 deletions examples/custom-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ Run the following steps from the root of this directory to install the custom AP
You can define custom field by using `extends CustomField {}` where `CustomField` is a model from the base specification library, see an example below:

```typespec
import "@opportunity-stream/core"; // Import the base specification library
import "@common-grants/core"; // Import the base specification library
// Allows us to use models defined in the specification library
// without prefixing each model with `OpportunityStream.Models.`
using OpportunityStream.Models;
// without prefixing each model with `CommonGrants.Models.`
using CommonGrants.Models;
namespace CustomAPI.CustomModels;
Expand Down Expand Up @@ -89,10 +89,10 @@ model CustomOpportunity extends Opportunity {
And finally this custom field can be used to override the the routes from the base specification library.

```typespec
import "@opportunity-stream/core";
import "@common-grants/core";
import "./models.tsp"; // Import the custom field and model from above
using OpportunityStream;
using CommonGrants;
using Http;
namespace CustomAPI.CustomRoutes;
Expand Down
168 changes: 84 additions & 84 deletions examples/custom-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/custom-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"docs": "npm run typespec && npm run docs:build && npm run docs:preview"
},
"peerDependencies": {
"@opportunity-stream/core": "file:../../specs/opportunity-stream-core-0.1.0-alpha.2.tgz",
"@common-grants/core": "file:../../specs/common-grants-core-0.1.0-alpha.3.tgz",
"@typespec/compiler": "^0.63.0"
},
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-api/src/models.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "@opportunity-stream/core";
import "@common-grants/core";
import "@typespec/json-schema";

using JsonSchema;
using OpportunityStream;
using CommonGrants;

@jsonSchema
namespace CustomAPI.CustomModels;
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-api/src/routes.tsp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import "@typespec/http";
import "@typespec/rest";

import "@opportunity-stream/core";
import "@common-grants/core";

import "./models.tsp";

using OpportunityStream;
using CommonGrants;
using Http;

namespace CustomAPI.CustomRoutes;
Expand Down
Loading

0 comments on commit 2841612

Please sign in to comment.