0

I want to generate different example values for the same complex object, for eg:

public class RequestDto
{
  // ...

  public class EntityDto SomeEntity {get; set;}
  public class EntityDto OtherEntity {get; set;}

  // ...
} 

public class EntityDto
{
  // ...

  /// <example>
  /// TOM
  /// </example>
  public string Name {get; set; }

  // ...
}

For the OtherEntity, I want the example value to show as "MARY" in the generated Open API spec say.

Anyone solved this before and can share some guidance ? Many thanks in advance.

juagicre
  • 1,065
  • 30
  • 42

1 Answers1

0

EntityDto.Name is a property which can be given one example, you can just add MARY there.

Or you can add the example summary to the SomeEntity and OtherEntity definitions directly like this:

/// <example>
/// TOM
/// </example>
public EntityDto SomeEntity {get; set; }


/// <example>
/// MARY
/// </example>
public EntityDto OtherEntity {get; set; }

and name property would be defined as:

/// <example>
/// Name of entity.
/// </example>
public string Name {get; set; }
juagicre
  • 1,065
  • 30
  • 42