encode method

  1. @override
void encode(
  1. KeyedArchive object
)
override

Implementation

@override
void encode(KeyedArchive object) {
  super.encode(object);

  if (name == null || location == null) {
    throw ArgumentError(
      "APIParameter must have non-null values for: 'name', 'location'.",
    );
  }

  object.encode("name", name);
  object.encode("description", description);
  object.encode("in", APIParameterLocationCodec.encode(location));

  if (location == APIParameterLocation.path) {
    object.encode("required", true);
  } else {
    object.encode("required", _required);
  }

  object.encode("deprecated", deprecated);

  if (location == APIParameterLocation.query) {
    object.encode("allowEmptyValue", allowEmptyValue);
  }

  object.encodeObject("schema", schema);
  object.encode("style", style);
  object.encode("explode", explode);
  object.encode("allowReserved", allowReserved);
  object.encodeObjectMap("content", content);
}