-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: Adds set of response wrapper models * refactor: Updates the Routes.Opportunities interface * feat: Adds an API service * refactor: Adds template to Opportunity model * docs: Updates README * refactor: Removes OpportunityExamples.complete Having the complete example introduces a TypeSpec compilation error when users define a custom field on the templated Opportunity * build: Bump prerelease version
- Loading branch information
Showing
10 changed files
with
202 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Responses.Error; | ||
|
||
@error | ||
model Error { | ||
@example(400) | ||
status: int32; | ||
|
||
/** Human-readable error message */ | ||
@example("Error") | ||
message: string; | ||
|
||
/** List of errors */ | ||
errors: Array<unknown>; | ||
} | ||
|
||
alias Unauthorized = Error & Http.UnauthorizedResponse; | ||
alias NotFound = Error & Http.NotFoundResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import "@typespec/http"; | ||
|
||
import "./errors.tsp"; | ||
import "./success.tsp"; | ||
|
||
namespace Responses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace Responses.Success; | ||
|
||
model Success { | ||
@example(200) | ||
status: int32; | ||
|
||
@example("Success") | ||
message: string; | ||
} | ||
|
||
/** Template for normal response data */ | ||
model Ok<T> extends Success { | ||
// Inherit the 200 status code | ||
...Http.OkResponse; | ||
|
||
/** Response data */ | ||
data: T; | ||
} | ||
|
||
/** Template for paginated responses */ | ||
model Paginated<T> extends Success { | ||
// Inherit the 200 status code | ||
...Http.OkResponse; | ||
|
||
/** Items from the current page */ | ||
@pageItems | ||
items: T[]; | ||
|
||
/** Details about the paginated results */ | ||
paginationInfo: { | ||
/** Current page number (indexing starts at 1) */ | ||
@example(1) | ||
page: int32; | ||
|
||
/** Number of items per page */ | ||
@example(20) | ||
pageSize: integer; | ||
|
||
/** Total number of items across all pages */ | ||
@example(100) | ||
totalItems: integer; | ||
|
||
/** Total number of pages */ | ||
@example(5) | ||
totalPages: integer; | ||
|
||
/** URL for the next page if available */ | ||
@example("/opportunities?page=2&pageSize=20") | ||
nextPageUrl?: string; | ||
|
||
/** URL for the previous page if available */ | ||
@example("/opportunities?page=1&pageSize=20") | ||
previousPageUrl?: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters