createModel method
Creates a Model for an API.
May throw NotFoundException. May throw TooManyRequestsException. May throw BadRequestException. May throw ConflictException.
Parameter apiId
:
The API identifier.
Parameter name
:
The name of the model. Must be alphanumeric.
Parameter schema
:
The schema for the model. For application/json models, this should be JSON
schema draft 4 model.
Parameter contentType
:
The content-type for the model, for example, "application/json".
Parameter description
:
The description of the model.
Implementation
Future<CreateModelResponse> createModel({
required String apiId,
required String name,
required String schema,
String? contentType,
String? description,
}) async {
ArgumentError.checkNotNull(apiId, 'apiId');
ArgumentError.checkNotNull(name, 'name');
ArgumentError.checkNotNull(schema, 'schema');
final $payload = <String, dynamic>{
'name': name,
'schema': schema,
if (contentType != null) 'contentType': contentType,
if (description != null) 'description': description,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/v2/apis/${Uri.encodeComponent(apiId)}/models',
exceptionFnMap: _exceptionFns,
);
return CreateModelResponse.fromJson(response);
}