documentSchemaObject method Null safety

  1. @override
APISchemaObject documentSchemaObject(
  1. APIDocumentContext context
)
override

Returns an APISchemaObject that represents this property.

Used during documentation.

Implementation

@override
APISchemaObject documentSchemaObject(APIDocumentContext context) {
  final prop = ManagedPropertyDescription._typedSchemaObject(type!)
    ..title = name;
  final buf = StringBuffer();

  // Add'l schema info
  prop.isNullable = isNullable;
  for (final v in validators) {
    v!.definition.constrainSchemaObject(context, prop);
  }

  if (isEnumeratedValue) {
    prop.enumerated = prop.enumerated!.map(convertToPrimitiveValue).toList();
  }

  if (isTransient) {
    if (transientStatus!.isAvailableAsInput &&
        !transientStatus!.isAvailableAsOutput) {
      prop.isWriteOnly = true;
    } else if (!transientStatus!.isAvailableAsInput &&
        transientStatus!.isAvailableAsOutput) {
      prop.isReadOnly = true;
    }
  }

  if (isUnique) {
    buf.writeln("No two objects may have the same value for this field.");
  }

  if (isPrimaryKey) {
    buf.writeln("This is the primary identifier for this object.");
  }

  if (defaultValue != null) {
    prop.defaultValue = defaultValue;
  }

  if (buf.isNotEmpty) {
    prop.description = buf.toString();
  }

  return prop;
}