docson icon indicating copy to clipboard operation
docson copied to clipboard

Title containing the 'error' word displays box with red text color

Open zbodor-gs opened this issue 5 years ago • 0 comments

Hi,

if I combine schemas with e.g. a oneOf keyword, and these schemas have titles, docson displays these titles in the signature boxes instead of 'any', this is cool. But if the title contains multiple words and one of them happens to be the "error" word, then the text color of this title changes to red:

{
  "oneOf": [
    {
      "title": "Response of succeeded execution",
      "type": "object",
      "properties": {
        ...
      }
    },
    {
      "title": "Response of failed execution with error object",
      "type": "object",
      "properties": {
        ...
      }
    }
  ]
}

renders as image

This is because of the way signature.html assigns classes to these boxes (... class="box-{{boxId}} signature-type-{{__type}} ...) and the way docson.js assigns value to the __type variable: ... schema.__type = schema.title; .... This results in the signature box having classes like: class="box-2 signature-type-Response of failed execution with error object .... And because of the whitespaces, 'error' is understood as separate class for the span, so docson.css colors it red.

This could be fixed e.g. by a custom handler which keeps only the first word for the signature-type- class, or by having two separate variables for these two purposes (class assignment and box content).

Zoli

zbodor-gs avatar Feb 06 '20 12:02 zbodor-gs