Skip to content

Creates invalid schema #1871

@aliksend

Description

@aliksend

🐛 Bug Report

Fastify with fastify-swagger creates invalid swagger schema. It should not contain $id fields.

To Reproduce

https://repl.it/repls/HoarseCoolEditor

And you'll got

    ...
    "paths": {
        "/first": {
            "get": {
                "responses": {
                    "200": {
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "a": {
                                        "type": "number"
                                    }
                                },
                                "$id": "A"
                            }
                        },
                        "description": "Default Response"
                    }
                }
            }
        },
    }
    ...

Notice the responses.200.schema.items.$id. Swagger generates error like

should NOT have additional properties
additionalProperty: $id

Your Environment

  • node version: 8
  • fastify version: 2.8.0
  • os: Linux

I plan to create PR with fix a bit later

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions