Skip to content
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

API Design Guidelines chapter 11: 'info' object, 'servers' object and cleanup #214

Merged
merged 8 commits into from
Jun 14, 2024
79 changes: 47 additions & 32 deletions documentation/API-design-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -1068,20 +1068,55 @@ Below considerations should be checked when an API is documented:
### 11.1 General Information

This part must include the following information:
- API Version in the next format: X.Y.Z.
- API title with public name.
- A brief description of the main functions of the API.
- API Version in the format defined in [Chapter 5. Versioning](#5-versioning)
- API Terms of Service.
- Contact information, with name, email and website of the API Holder.
- Licence information (name, website…)
- Schemes supported (HTTP, HTTPS…)
- Allowed response formats (“application/json”, “text/xml”…)
- Response format (“application/jwt”…)
- API server and base URL
- Global `tags` object if tags are used for API operations

<p align="center">
<img src="./images/guidelines-fig-14.png" width="400"/>
</p>
The `info` object shall have the following content:

```yaml
info:
# title without "API" in it, e.g. "Number Verification"
title: Number Verification
# description explaining the API, part of the API documentation
# text explaining how to fill the "Authorization and authentication" - see section 11.6
description: |
This API allows to verify that the provided mobile phone number is the one used in the device. It
verifies that the user is using a device with the same mobile phone number as it is declared.
### Authorization and authentication
CAMARA guidelines defines a set of authorization flows ...
# API version - Aligned to SemVer 2.0 according to CAMARA versioning guidelines
version: 1.0.1
# Link to the page that describes the terms of service - to be replaced by the provider's terms
termsOfService: http://example.com/terms/
# Contact information: name, email, URL
contact:
rartych marked this conversation as resolved.
Show resolved Hide resolved
name: API Support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One doubt
which values are expected to be used in the APIs (I assume we will have to insert this information in every API so i think we could have some alignment regarding the value to be indicated to use the same approach among APIs or it is up to the WG the value to be provided).
Anycase, all of them (name, email, url) has to be indicated within the yaml, doesn`t?

name: support -> e.g. Blockchain Public Address Support
email: mail distribution list of the WG -> e.g. sp-bpa@lists.camaraproject.org
url: link to the WG site in CAMARA gtihub -> e.g. https://github.com/camaraproject/BlockchainPublicAddress

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is assumed that the contact information will be changed by each API Provider (Operator or Aggregator) when publishing API specification as the documentation for their service - possibly it should be explained in API Design Guidelines here in chapter 11.
When yaml is hosted in CAMARA Github all contact info is in main README.md
@tanjadegroot @hdamker WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should include the information that is relevant for CAMARA in our specs, as each API provider will adapt our OAS spec to whatever template or format they use in their portals. title and version are the only required sub-sections for info section. If we decided to add the contact sub-section, I would fill it with contact details for CAMARA.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had added such contact subsection with Camara relevant details in the common.yaml as a part of the last release and would personally prefer this format as well.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the discussion in Release Management: https://wiki.camaraproject.org/display/CAM/2024-06-04+Release+WG+Minutes and #214 (comment) I have removed contact and termsOfService from the info object and added some explanation.

See the changes: 2421afb.

email: support@example.com
# Link to the provider's support page.
url: http://www.example.com/support
# Name of the license and a URL to the license description
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
```

The `servers` object shall have the following content:

```yaml
servers:
# apiRoot variable and the fixed base path containing <api-name> and <api-version> as defined in chapter 5
- url: "{apiRoot}/quality-on-demand/vwip"
variables:
apiRoot:
default: http://localhost:9091
description: API root, defined by the service provider, e.g. `api.example.com` or `api.example.com/somepath`
```

### 11.2 Published Routes

Expand All @@ -1093,35 +1128,27 @@ This part must contain the list of published functions, with the following descr
- Optionally `tags` object for each API operation - Title Case is the recommended style for tag names.
- Request param list, making reference to "Request params" part.
- Supported responses list, describing success and errors cases.

<p align="center">
<img src="./images/guidelines-fig-15.png" width="400"/>
</p>
- Allowed content type (“application/json”, “text/xml”…)

### 11.3 Request Parameters

This part contains a list of expected payload requests, if any. This description should have the following items:
- Parameter name, used to reference it in other sections
- Parameter description
- Parameter place (header, route…)
- Type (basic types like chains, integers, complex objects,...)
- Type (basic types like strings, integers, complex objects,...)
- Required field or optional flag

<p align="center">
<img src="./images/guidelines-fig-16.png" width="400"/>
</p>

### 11.4 Response Structure

This part describes the list of possible messages returned by the API. It also includes the description of the error response objects:
- Name of the response object, used to refer to it in other sections.
- Response object description.
- Object type (basic types like string, integer... or even more complex objects defined in the "Data definition" part...)
- Allowed content type (“application/json”, “text/xml”…)
- Metadata links (HATEOAS)

<p align="center">
<img src="./images/guidelines-fig-17.png" width="400"/>
</p>


### 11.5 Data Definitions
Expand All @@ -1140,21 +1167,9 @@ This part captures a detailed description of all the data structures used in the
- Integer ones: Format (int32, int64…), min value.


In this part, the error response structure must also be defined, which must be as follows:
- Type (Array, Integer, Object …)
- Mandatory fields of the structure
- Properties:
- Error Code
- Type (Array, Integer…)
- Error codes supported, as Enum list
- Error description
- Type (Array)
- Min longitude
- Max longitude
In this part, the error response structure must also be defined following the guidelines in [Chapter 6. Error Responses](#6-error-responses).


<p align="center">
<img src="./images/guidelines-fig-18.png" width="400"/>
</p>

#### 11.5.1 Usage of discriminator
As mentioned in OpenAPI doc [here](https://spec.openapis.org/oas/v3.0.3#discriminator-object) usage of discriminator may
Expand Down