-
Notifications
You must be signed in to change notification settings - Fork 5
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
[ADR] API contract conventions #46
Comments
Remember that ADRs are publicly available hence do not include any confidential information in the issue description! |
Querying revisitOdata query implementation does not fit well with our APIs. Other standards don't seem to help us or the consumer either. So we will build a strong set of custom querying features based on DirectUs fields:
ResponsesSome standards make use of wrapper types like meta, data and more. In general we follow the way DirectUs structures responses. type Wrapped = {
data?: object | object[]; // Can be omitted if there is an error
meta?: Meta; // Can be omitted for single item requests
error?: ErrorResponse; // Can be omitted if there is no error or 'errors' is defined
errors?: ErrorResponse[]; // Can be omitted if there is no error or 'error' is defined
};
interface Meta {
total: number;
skipped: number;
limit: number;
// Other optional properties
}
interface ErrorResponse {
message: string;
code?: string;
// Other optional properties
}
// examples:
const errorResponse: Wrapped = {
error: {
code: 'invalid-query',
message: "Invalid query: 'foo' is not a valid query parameter",
},
};
const singleItemResponse: Wrapped = {
data: {
id: '123',
name: 'John Doe',
},
};
const multipleItemsResponse: Wrapped = {
data: [
{
id: '123',
name: 'John Doe',
},
{
id: '456',
name: 'Jane Doe',
},
],
meta: {
total: 7,
skipped: 0,
limit: 2,
},
}; |
I like the proposal @JakubC-projects. We could consider using The type |
Context
For the Core APIs we are setting a standard for how OpenAPIs should look like within BCC.
Proposition
Enums
The values used within Enums will be PascalCase. This is to stay backwards compatible with previously connected systems.
Timestamps
Dates where time is irrelevant (such as birth dates, deceased dates, contract dates etc.) should look like:
2022-05-03
. These dates should not have a timezone or time component.Regular timestamps should conform to the iso 8601. This means that a timezone and time component is stored.
Null values
Should be looked at on a case by case basis.
Querying
For querying in our APIs we want to build according to the Odata query syntax. This syntax should only be implemented according to need. For now we are interesting in using:
The text was updated successfully, but these errors were encountered: