lbovet / docson

Documentation for your JSON types
Apache License 2.0
491 stars 97 forks source link

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

Open zbodor-gs opened 4 years ago

zbodor-gs commented 4 years ago

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