Repository: fastify/fastify
File: lib/schemas.js (JavaScript)

Code before:
    routeSchemas.querystring = routeSchemas.query
  }

  generateFluentSchema(routeSchemas)

  for (const key of SCHEMAS_SOURCE) {
    const schema = routeSchemas[key]
    if (schema && !isCustomSchemaPrototype(schema)) {
      if (key === 'body') {
        const contentProperty = routeSchemas.body.content
        if (contentProperty) {
          const keys = Object.keys(contentProperty)
          for (let i = 0; i < keys.length; i++) {
            const mediaName = keys[i]
            const contentSchema = contentProperty[mediaName].schema
            if (!contentSchema) {
              throw new FST_ERR_SCH_CONTENT_MISSING_SCHEMA(mediaName)
            }
            routeSchemas.body.content[mediaName].schema = getSchemaAnyway(contentSchema, serverOptions.jsonShorthand)
          }
        } else {
          routeSchemas.body = getSchemaAnyway(routeSchemas.body, serverOptions.jsonShorthand)
        }
      } else {
        routeSchemas[key] = getSchemaAnyway(schema, serverOptions.jsonShorthand)
      }
    }
  }

  if (routeSchemas.response) {
    const httpCodes = Object.keys(routeSchemas.response)
    for (const code of httpCodes) {
      if (isCustomSchemaPrototype(routeSchemas.response[code])) {
        continue
      }

      const contentProperty = routeSchemas.response[code].content

      let hasContentMultipleContentTypes = false
      if (contentProperty) {
        const keys = Object.keys(contentProperty)
        for (let i = 0; i < keys.length; i++) {
          const mediaName = keys[i]
          if (!contentProperty[mediaName].schema) {
            if (keys.length === 1) { break }
            throw new FST_ERR_SCH_CONTENT_MISSING_SCHEMA(mediaName)
          }
          routeSchemas.response[code].content[mediaName].schema = getSchemaAnyway(contentProperty[mediaName].schema, serverOptions.jsonShorthand)
          if (i === keys.length - 1) {
            hasContentMultipleContentTypes = true
          }

Review comment (suggestion):
Too many branches IMHO

```suggestion
      if (key === 'body') {
        const contentProperty = schema.content
        if (contentProperty) {
          const keys = Object.keys(contentProperty)
          for (let i = 0; i < keys.length; i++) {
            const mediaName = keys[i]
            const contentSchema = contentProperty[mediaName].schema
            if (!contentSchema) {
              throw new FST_ERR_SCH_CONTENT_MISSING_SCHEMA(mediaName)
            }
            routeSchemas.body.content[mediaName].schema = getSchemaAnyway(contentSchema, serverOptions.jsonShorthand)
          }
          continue
        }
      }
      routeSchemas[key] = getSchemaAnyway(schema, serverOptions.jsonShorthand)
```

Code after:
    routeSchemas.querystring = routeSchemas.query
  }

  generateFluentSchema(routeSchemas)

  for (const key of SCHEMAS_SOURCE) {
    const schema = routeSchemas[key]
    if (schema && !isCustomSchemaPrototype(schema)) {
      if (key === 'body' && schema.content) {
        const contentProperty = schema.content
        const keys = Object.keys(contentProperty)
        for (let i = 0; i < keys.length; i++) {
          const contentType = keys[i]
          const contentSchema = contentProperty[contentType].schema
          if (!contentSchema) {
            throw new FST_ERR_SCH_CONTENT_MISSING_SCHEMA(contentType)
          }
          routeSchemas.body.content[contentType].schema = getSchemaAnyway(contentSchema, serverOptions.jsonShorthand)
        }
        continue
      }
      routeSchemas[key] = getSchemaAnyway(schema, serverOptions.jsonShorthand)
    }
  }

  if (routeSchemas.response) {
    const httpCodes = Object.keys(routeSchemas.response)
    for (const code of httpCodes) {
      if (isCustomSchemaPrototype(routeSchemas.response[code])) {
        continue
      }

      const contentProperty = routeSchemas.response[code].content

      let hasContentMultipleContentTypes = false
      if (contentProperty) {
        const keys = Object.keys(contentProperty)
        for (let i = 0; i < keys.length; i++) {
          const mediaName = keys[i]
          if (!contentProperty[mediaName].schema) {
            if (keys.length === 1) { break }
            throw new FST_ERR_SCH_CONTENT_MISSING_SCHEMA(mediaName)
          }
          routeSchemas.response[code].content[mediaName].schema = getSchemaAnyway(contentProperty[mediaName].schema, serverOptions.jsonShorthand)
          if (i === keys.length - 1) {
            hasContentMultipleContentTypes = true
          }
        }
      }

      if (!hasContentMultipleContentTypes) {