Commits (4)
protoc/
go-stubs/
ruby-stubs/
.proto-gen/
python-stubs/
.vscode/
\ No newline at end of file
......@@ -1854,16 +1854,10 @@ components:
properties:
msgProtocol:
description: 'Numerical value corresponding to the application layer protocol supported by the service consumer. For the msgProtocol, the following values are currently defined (see note):
0 = MQTT v3.1.0
1 = MQTT v3.1.1
2 = MQTT v5
3 = MQTT-SN
4 = AMQP 1.0'
items:
enum:
......
......@@ -16,4 +16,4 @@ This repository contains OpenAPIs descriptions for the interfaces specified in E
## License
Unless specified otherwise, the content of this repository and the files contained are released under the BSD-3-Clause license.
See the attached LICENSE file or visit https://forge.etsi.org/legal-matters.
See the attached LICENSE file or visit https://forge.etsi.org/legal-matters.
\ No newline at end of file
# Protobuf Schema Generation
[OpenAPI Generator](https://openapi-generator.tech) is used to generate protobuf schema (`.proto3`) files from OpenAPI specifications of MEC030 V2X Information Services API.
>**NOTE:** At the time of writing, the tool does not support OAS 3.1 version and we have to first convert the [V2X Information Service API](./MEC030_V2XInformationServices.yaml) to OAS 3.0 for generating protobuf schema.
1. Convert OAS for [V2X Information Service API](./MEC030_V2XInformationServices.yaml) from 3.1 to 3.0​
- Change the value of `openapi` field from 3.1.0 to 3.0.0​
- Use this [VS code extension](https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi) to see the errors in the downgraded YAML (v3.0)​
- Manually fix the errors​
- mostly related to `examples` <--> `example` interchange​
- or some 3.1 fields that are not supported in 3.0​ (comment them out)
2. Generate proto files
- Install the `openapi-generator-cli.jar` using the installation procedure mentioned [here](https://openapi-generator.tech/docs/installation#jar).
- Generate the proto files using the following command
```sh
$ java -jar openapi-generator-cli.jar generate -i MEC030_V2XInformationServices.yaml -g protobuf-schema -o proto3/ --package-name mec030
```
3. Carefully inspect the generated `.proto` files for any inconsistencies. Some of the things to look out for:
- Proto3 generated files for enumerations, structures containing allOf, oneOf, anyOf etc. may need to be touched manually
- Check that all the nested models are being _imported_ correctly in their parent models
- Remove redundant proto files
4. Validate protobuf schema by generating code from proto3 descriptions in different languages. See [this section](#code-generation-from-proto3) for more details.
# Code Generation from proto3
Below are some code generation examples for Python, Go and Ruby. For other languages, please refer to https://grpc.io/docs/quickstart/.
### Python
1. Install the grpcio-tools package
```sh
$ pip install grpcio-tools
```
2. Create a directory for generated Python stubs
```sh
$ mkdir python-stubs
```
3. Run the following commands from the root of the directory containing this README that you are reading.
- Models:
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs ./proto3/models/*
```
The above command will generate .py files for all the data models in the ./models directory
- Services:
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs --grpc_python_out=./python-stubs ./proto3/services/<*_service>.proto
```
The above command will generate two files for the V2X Information Services:
- <*_servic_pb2>.py_: containing the python data models used in the service file
- <*_service_pb2_grpc>.py_: containing all the classes and functions needed for the supported HTTP methods in the service file
### Go
1. Install protocol buffer compiler
```sh
$ apt install -y protobuf-compiler
```
2. Install Go plugins for `protoc`
```sh
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
```
```sh
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
```
3. Update `PATH` so `protoc` can find the plugins
```sh
$ export PATH="$PATH:$(go env GOPATH)/bin"
```
4. Define a go package by appending `option go_package = "./mec030.services.v2xinformationservices";` in all .proto files like this:
```Go
...
syntax = "proto3";
package mec030.services.v2xinformationservices;
option go_package = "./mec030.services.v2xinformationservices";
import public "models/<xyz>.proto";
...
```
5. Generate Go code for models and services
```sh
$ mkdir go-stubs
$ protoc --go_out=./go-stubs ./proto3/models/* -I./proto3
$ protoc --go_out=./go-stubs ./proto3/services/* --go-grpc_out=go-stubs -I./proto3
```
> The generated `<data_model>.pb.go` files will contain all the protocol buffer code to populate, serialize, and retrieve request and response message types defined in the `models` folder.
> And the `<*_service_grpc>.pb.go` will contain the stubs for the methods defined in the `<*_service>.proto` file.
### Ruby
1. Install gRPC Ruby Plugin and required tools
```sh
$ gem install grpc
$ sudo apt install ruby-grpc-tools
```
2. Generate code
```sh
$ mkdir ruby-stubs
```
Run the following command to create Ruby modules for all the data models defined in the proto files.
```sh
$ grpc_tools_ruby_protoc -I./proto3 --ruby_out=ruby-stubs ./proto3/models/*
```
Run the following command to generate `<*_service_pb>.rb` and `<*_service_services_pb>.rb` files, containing stub and service classes for the endpoints and methods defined in MEC030 V2X Information Services.
```sh
$ grpc_tools_ruby_protoc -I./proto3 --ruby_out=ruby-stubs --grpc_out=ruby-stubs ./proto3/services/*
```
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
.openapi-generator-ignore
README.md
models/cell_id.proto
models/earfcn.proto
models/ecgi.proto
models/fdd_info.proto
models/info_connection.proto
models/info_protocol.proto
models/link_type.proto
models/links.proto
models/links1.proto
models/links2.proto
models/links3.proto
models/location_info.proto
models/location_info_geo_area.proto
models/msg_type.proto
models/pc5_neighbour_cell_info.proto
models/pc5_provisioning_info.proto
models/pc5_provisioning_info_pro_info_pc5.proto
models/plmn.proto
models/pred_qos_subscription.proto
models/predicted_qos.proto
models/predicted_qos_routes.proto
models/predicted_qos_routes_route_info.proto
models/prediction_area.proto
models/problem_details.proto
models/prov_chg_pc5_notification.proto
models/prov_chg_pc5_subscription.proto
models/prov_chg_pc5_subscription_filter_criteria.proto
models/prov_chg_uu_mbms_notification.proto
models/prov_chg_uu_mbms_subscription.proto
models/prov_chg_uu_mbms_subscription_filter_criteria.proto
models/prov_chg_uu_uni_notification.proto
models/prov_chg_uu_uni_subscription.proto
models/prov_chg_uu_uni_subscription_filter_criteria.proto
models/qos.proto
models/qos_kpi.proto
models/qos_pred_filter_criteria.proto
models/route_info.proto
models/routes.proto
models/stream.proto
models/subscription_link_list.proto
models/subscriptions.proto
models/tdd_info.proto
models/test_notification.proto
models/test_notification_links.proto
models/time_stamp.proto
models/transmission_bandwidth.proto
models/transmission_bandwidth_transmission_bandwidth.proto
models/uu_mbms_neighbour_cell_info.proto
models/uu_mbms_provisioning_info.proto
models/uu_mbms_provisioning_info_pro_info_uu_mbms.proto
models/uu_uni_neighbour_cell_info.proto
models/uu_unicast_provisioning_info.proto
models/uu_unicast_provisioning_info_pro_info_uu_unicast.proto
models/v2x_application_server.proto
models/v2x_msg_distribution_server.proto
models/v2x_msg_distribution_server_info.proto
models/v2x_msg_filter_criteria.proto
models/v2x_msg_notification.proto
models/v2x_msg_notification_links.proto
models/v2x_msg_properties_values.proto
models/v2x_msg_publication.proto
models/v2x_msg_subscription.proto
models/v2x_msg_subscription_filter_criteria.proto
models/v2x_server_usd.proto
models/v2x_server_usd_sdp_info.proto
models/v2x_server_usd_tmgi.proto
models/websock_notif_config.proto
services/qo_s_service.proto
services/queries_service.proto
services/subscription_service.proto
services/v2_x_msg_service.proto
5.4.0
\ No newline at end of file
# gPRC for mec030
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
## Overview
These files were generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
- API version: 3.1.1
- Package version:
- Build package: org.openapitools.codegen.languages.ProtobufSchemaCodegen
For more information, please visit [https://forge.etsi.org/rep/mec/gs030-vis-api](https://forge.etsi.org/rep/mec/gs030-vis-api)
## Usage
Below are some usage examples for Python, Go and Ruby. For other languages, please refer to https://grpc.io/docs/quickstart/.
### Python
1. Install the grpcio-tools package
```sh
$ pip install grpcio-tools
```
2. Create a directory for generated Python stubs
```sh
$ mkdir python-stubs
```
3. Run the following commands from the root of the directory containing this README that you are reading.
- Models:
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs ./proto3/models/*
```
The above command will generate .py files for all the data models in the ./models directory
- Services:
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs --grpc_python_out=./python-stubs ./proto3/services/<*_service>.proto
```
The above command will generate two files for the V2X Information Services:
- <*_servic_pb2>.py_: containing the python data models used in the service file
- <*_service_pb2_grpc>.py_: containing all the classes and functions needed for the supported HTTP methods in the service file
### Go
1. Install protocol buffer compiler
```sh
$ apt install -y protobuf-compiler
```
2. Install Go plugins for `protoc`
```sh
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
```
```sh
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
```
3. Update `PATH` so `protoc` can find the plugins
```sh
$ export PATH="$PATH:$(go env GOPATH)/bin"
```
4. Define a go package by appending `option go_package = "./mec030.services.v2xinformationservices";` in all .proto files like this:
```Go
...
syntax = "proto3";
package mec030.services.v2xinformationservices;
option go_package = "./mec030.services.v2xinformationservices";
import public "models/<xyz>.proto";
...
```
5. Generate Go code for models and services
```sh
$ mkdir go-stubs
$ protoc --go_out=./go-stubs ./proto3/models/* -I./proto3
$ protoc --go_out=./go-stubs ./proto3/services/* --go-grpc_out=go-stubs -I./proto3
```
> The generated `<data_model>.pb.go` files will contain all the protocol buffer code to populate, serialize, and retrieve request and response message types defined in the `models` folder.
> And the `<*_service_grpc>.pb.go` will contain the stubs for the methods defined in the `<*_service>.proto` file.
### Ruby
1. Install gRPC Ruby Plugin and required tools
```sh
$ gem install grpc
$ sudo apt install ruby-grpc-tools
```
2. Generate code
```sh
$ mkdir ruby-stubs
```
Run the following command to create Ruby modules for all the data models defined in the proto files.
```sh
$ grpc_tools_ruby_protoc -I./proto3 --ruby_out=ruby-stubs ./proto3/models/*
```
Run the following command to generate `<*_service_pb>.rb` and `<*_service_services_pb>.rb` files, containing stub and service classes for the endpoints and methods defined in MEC030 V2X Information Services.
```sh
$ grpc_tools_ruby_protoc -I./proto3 --ruby_out=ruby-stubs --grpc_out=ruby-stubs ./proto3/services/*
```
```
\ No newline at end of file
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -16,6 +18,6 @@ package mec030;
message CellId {
// E-UTRAN Cell Identity as a bit string (size (28)).
string cell_id = 1;
string cellId = 1;
}
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -16,6 +18,6 @@ package mec030;
message Earfcn {
// E-UTRA Absolute Radio Frequency Channel Number, range (0... 65535)
int32 earfcn = 1;
int32 earfcn = 2;
}
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -17,7 +19,7 @@ import public "models/plmn.proto";
message Ecgi {
CellId cell_id = 1;
CellId cellId = 1;
Plmn plmn = 2;
......
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -17,12 +19,12 @@ import public "models/transmission_bandwidth.proto";
message FddInfo {
Earfcn dl_earfcn = 1;
Earfcn dlEarfcn = 1;
TransmissionBandwidth dl_transmission_bandwidth = 2;
TransmissionBandwidth dlTransmissionBandwidth = 2;
Earfcn ul_earfcn = 3;
Earfcn ulEarfcn = 3;
TransmissionBandwidth ul_transmission_bandwidth = 4;
TransmissionBandwidth ulTransmissionBandwidth = 4;
}
/*
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec030;
message InfoConnection {
// IP address of the V2X Message Distribution Server.
string ipAddress = 1;
// Port number of the V2X Message Distribution Server.
int32 port_number = 2;
}
/*
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec030;
message InfoProtocol {
// Numerical value corresponding to the application layer protocol supported by the service consumer. For the msgProtocol, the following values are currently defined (see note): 0 = MQTT v3.1.0 1 = MQTT v3.1.1 2 = MQTT v5 3 = MQTT-SN 4 = AMQP 1.0
enum MsgProtocolEnum {
_0 = 0;
_1 = 1;
_2 = 2;
_3 = 3;
_4 = 4;
}
MsgProtocolEnum msgProtocol = 1;
// Implementation specifics of application layer protocol, e.g. programming language.
string protImplementation = 2;
}
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -15,7 +17,7 @@ package mec030;
message LinkType {
// The URI referring to the subscription.
// URI referring to a resource
string href = 1;
}
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -14,7 +16,7 @@ package mec030;
import public "models/link_type.proto";
message ProvChgPc5SubscriptionLinks {
message Links {
LinkType self = 1;
......
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -14,7 +16,7 @@ package mec030;
import public "models/link_type.proto";
message ProvChgUuUniSubscriptionLinks {
message Links1 {
LinkType self = 1;
......
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -13,11 +15,12 @@ syntax = "proto3";
package mec030;
import public "models/link_type.proto";
import public "models/subscriptions.proto";
option java_outer_classname = "V2xMsgSubscriptionLinksProto";
message V2xMsgSubscriptionLinks {
message Links2 {
LinkType self = 1;
repeated Subscriptions subscriptions = 2;
}
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -14,8 +16,8 @@ package mec030;
import public "models/link_type.proto";
message ProvChgUuMbmsSubscriptionLinks {
message Links3 {
LinkType self = 1;
LinkType subscription = 1;
}
/*
ETSI GS MEC 030 V2X Information Service API
ETSI GS MEC 030 V2X Information Service API described using OpenAPI.
The version of the OpenAPI document: 2.1.1
ETSI GS MEC 030 V2X Information Services API
ETSI GS MEC 030 V2X Information Services API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
......@@ -19,6 +21,6 @@ message LocationInfo {
Ecgi ecgi = 1;
LocationInfoGeoArea geo_area = 2;
LocationInfoGeoArea geoArea = 2;
}