: "Add Person"
                      content:
                        text/plain:
                          schema:
                            type: "string"
            components:
              schemas:
                Person:
                  required:
                  - "address"
                  properties:
                    address:
                      type: "array"
                      items:
                        type: "string"
            """.trimIndent()
        )
    }

    @Test
    fun `payload is a list of nullables`() {
        val feature = parseGherkinStringToFeature(
            """
            Feature: Person API
            
            Scenario: Add Person
              Given type Person
              | address | (string?*) |
              When POST /person
              And request-body (Person)
              Then status 200
              And response-body (string)
            """.trimIndent()
        )
        val openAPI = feature.toOpenApi()

        with(OpenApiSpecification("/file.yaml", openAPI).toFeature()) {
            assertThat(
                this.matches(
                    HttpRequest(
                        "POST",
                        "/person",
                        body = parsedJSON("""{"address": [null, "Baker Street"]}""")
                    ), HttpResponse.OK("success")
                )
            ).isTrue
        }

        val openAPIYaml = Yaml.mapper().writeValueAsString(openAPI)
        portableComparisonAcrossBuildEnvironments(
            openAPIYaml,
            """
            ---
            openapi: "3.0.1"
            info:
              title: "Person API"
              version: "1"
            paths:
              /person:
                post:
                  summary: "Add Person"
                  parameters: []
                  requestBody:
                    content:
                      application/json:
                        schema:
                          ${"$"}ref: "#/components/schemas/Person"
                  responses:
                    200:
                      description: "Add Person"
                      content:
                        text/plain:
                          schema:
                            type: "string"
            components:
              schemas:
                Person:
                  required:
                  - "address"
                  properties:
                    address:
                      type: "array"
                      items:
                        type: "string"
                        nullable: true
            """.trimIndent()
        )
    }

    @Test
    fun `same request headers from multiple scenarios`() {
        val feature = parseGherkinStringToFeature(
            """
            Feature: API
            
            Scenario: Get details
              When GET /data
              And request-header X-Data (string)
              Then status 200
              And response-body (string)

            Scenario: Get details
              When GET /data
              And request-header X-Data (string)
              Then status 200
              And response-body (string)
            """.trimIndent()
        )
        val openAPI = feature.toOpenApi()

        with(OpenApiSpecification("/file.yaml", openAPI).toFeature()) {
            assertThat(
                this.matches(
                    HttpRequest(
                        "GET",
                        "/data",
                        headers = mapOf("X-Data" to "data")
                    ), HttpResponse.OK("success")
                )
            ).isTrue
        }

        val openAPIYaml = Yaml.mapper().writeValueAsString(openAPI)
        portableComparisonAcrossBuildEnvironments(
            openAPIYaml,
            """
            ---
            openapi: "3.0.1"
            info:
              title: "API"
              version: "1"
            paths:
              /data:
                get:
                  summary: "Get details"
                  parameters:
                  - name: "X-Data"
                    in: "header"
                    required: true
                    schema:
                      type: "string"
                  responses:
                    200:
                      description: "Get details"
                      content:
                        text/plain:
                          schema:
                            type: "string"
            """.trimIndent()
        )
    }

    @Test
    fun `same response headers from multiple scenarios`() {
        val feature = parseGherkinStringToFeature(
            """
            Feature: API
            
            Scenario: Get details
              When GET /data
              Then status 200
              And response-header X-Data (string)
              And response-body (string)

            Scenario: Get details
              When GET /data
              Then status 200
              And response-header X-Data (string)
              And response-body (string)
            """.trimIndent()
        )
        val openAPI = feature.toOpenApi()

        with(OpenApiSpecification("/file.yaml", openAPI).toFeature()) {
            assertThat(
                this.matches(
                    HttpRequest(
                        "GET",
                        "/data"
                    ), HttpResponse.OK("success").copy(headers = mapOf("X-Data" to "data"))
                )
            ).isTrue
        }

        val openAPIYaml = Yaml.mapper().writeValueAsString(openAPI)
        portableComparisonAcrossBuildEnvironments(
            openAPIYaml,
            """
            ---
            openapi: "3.0.1"
            info:
              title: "API"
              version: "1"
            paths:
              /data:
                get:
                  summary: "Get details"
                  parameters: []
                  responses:
                    200:
                      description: "Get details"
                      headers:
                        X-Data:
                          required: true
                          schema:
                            type: "string"
                      content:
                        text/plain:
                          schema:
                            type: "string"
            """.trimIndent()
        )
    }

    @Test
    fun `different response headers from multiple scenarios with the same method and path`() {
        val feature = parseGherkinStringToFeature(
            """
            Feature: API
            
            Scenario: Get details
              When GET /data
              Then status 200
              And response-header X-Data-One (string)
              And response-body (string)

            Scenario: Get details
              When GET /data
              Then status 200
              And response-header X-Data-Two (string)
              And response-body (string)
            """.trimIndent()
        )
        val openAPI = feature.toOpenApi()

        with(OpenApiSpecification("/file.yaml", openAPI).toFeature()) {
            assertThat(
                this.matches(
                    HttpRequest(
                        "GET",
                        "/data"
                    ), HttpResponse.OK("success").copy(headers = mapOf("X-Data-One" to "data"))
                )
            ).isTrue
            assertThat(
                this.matches(
                    HttpRequest(
                        "GET",
                        "/data"
                    ), HttpResponse.OK("success").copy(headers = mapOf("X-Data-Two" to "data"))
                )
            ).isTrue
            assertThat(
                this.matches(
                    HttpRequest(
                        "GET",
                        "/data"
                    ), HttpResponse.OK("success")
                )
            ).isTrue
        }

        val openAPIYaml = Yaml.mapper().writeValueAsString(openAPI)
        portableComparisonAcrossBuildEnvironments(
            openAPIYaml,
            """
            ---
            openapi: "3.0.1"
            info:
              title: "API"
              version: "1"
            paths:
              /data:
                get:
                  summary: "Get details"
                  parameters: []
                  responses:
                    200:
                      description: "Get details"
                      headers:
                        X-Data-One:
                          required: false
                          schema:
                            type: "string"
                        X-Data-Two:
                          required: false
                          schema:
                            type: "string"
                      content:
                        text/plain:
                          schema:
                            type: "string"
            """.trimIndent()
        )
    }

    @Test
    fun `different request headers from multiple scenarios with the same method and path`() {
        val feature = parseGherkinStringToFeature(
            """
            Feature: API
            
            Scenario: Get details
              When GET /data
              And request-header X-Data-One (string)
              Then status 200
              And response-body (string)

            Scenario: Get details
              When GET /data
              And request-header X-Data-Two (string)
              Then status 200
              And response-body (string)
            """.trimInd