Handling Nullables in Swagger


#1

This question is actually need a clarification.

I have two classes in C#

public class Parameter
{
    public long Id { get; set; }
    public string Name { get; set; }
    public string Value { get; set; }
}
public class Procedure : DTOEntityBase
{
    public string ProcedureName { get; set; }
    public List<Parameter> Paramters { get; set; }
}

I have implemented the json-api therefore I overwrite the ISchemaFilter.Apply() and convert these simple object to jason-api format. Something like this

        var obj = GetDto(type);
        schema.example = obj;
        schema.@default = obj;

At /Swagger/ui/index page I got error on browser console that redireced me to following issue https://github.com/OAI/OpenAPI-Specification/issues/229

To avoid nulls i manually filled dummy data recursively. This at least bring back the page /Swagger/ui/index but still there is few discrepancies. The most notable is my inner object is partially visible see: “type”: “parameters” Names and Values are still missing.

{
  "data": {
    "attributes": {
      "procedure-name": "1"
    },
    "relationships": {
      "paramters": {
        "data": [
          {
            "id": 0,
            "type": "parameters"
          }
        ]
      }
    }
  }
}

Is this Ok and an expected behavior?

The second thing is – only at right side of the page I can see this Model-Schema. But the top part of the page with Model-Schema remains blank.


#2

Could it be due to a typo? I see you have both “parameter” and “paramter”


#3

keen eyes, But it is just to distinguish variable with class name (for the time being)