Add custom properties to swagger.json definition file

Add custom properties to swagger.json definition file

  

Hi,

I'm looking for a way to add more information in the swagger.json definition file. 

I need to add multiple HTTP status response to the generated definition. (200 is the only one i can see) and also, add some extended properties (using the "x-") as seen in the specification.

I looked up in the documentation and found out a way to alter the returning status code using the "SetStatusCode" action but it is not reflected in the swagger definition file.

I also found a way to add more properties to the definition by implementing some sort o "middleware" that will grab the platform auto generated definition, add what i need, and return the result to the client, but before i procede on this implementation i would like to know if there is a better way of doing it.

An example of what i need to add (in red) is below:

...

"responses":{  
   "200":{  
      "description":"OK.",
      "schema":{  
         "$ref":"#/definitions/Aluno"
      }
   },
   "404":{  
      "description":"Aluno não encontrado."
   },
   "500":{  
      "description":"Erro interno."
   }

},
"x-mask":{  
   "nascimento":"dd/MM/yyyy"
}

...


Solution

Hi Fernando,


Allowing the swagger costumization is indeed in the improvements roadmap for the feature but at this point there is no planned timeline (or even commitment) for it.


In the meanwhile, if you already found a way to do it can you share some details about it here? It would be nice for other developers that have the similar requirements. 


Regards,

João Rosado 

Solution

Thank's for clearing my dought João.

Right now I'm trying to test the concept and validate it. When I have something more concrete I'll post it here.