createModel method

Future<Model> createModel({
  1. required String contentType,
  2. required String name,
  3. required String restApiId,
  4. String? description,
  5. String? schema,
})

Adds a new Model resource to an existing RestApi resource.

May throw BadRequestException. May throw UnauthorizedException. May throw NotFoundException. May throw ConflictException. May throw LimitExceededException. May throw TooManyRequestsException.

Parameter contentType : Required The content-type for the model.

Parameter name : Required The name of the model. Must be alphanumeric.

Parameter restApiId : Required The RestApi identifier under which the Model will be created.

Parameter description : The description of the model.

Parameter schema : The schema for the model. For application/json models, this should be JSON schema draft 4 model.

Implementation

Future<Model> createModel({
  required String contentType,
  required String name,
  required String restApiId,
  String? description,
  String? schema,
}) async {
  ArgumentError.checkNotNull(contentType, 'contentType');
  ArgumentError.checkNotNull(name, 'name');
  ArgumentError.checkNotNull(restApiId, 'restApiId');
  final $payload = <String, dynamic>{
    'contentType': contentType,
    'name': name,
    if (description != null) 'description': description,
    if (schema != null) 'schema': schema,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/restapis/${Uri.encodeComponent(restApiId)}/models',
    exceptionFnMap: _exceptionFns,
  );
  return Model.fromJson(response);
}