Skip to content

OAS 'additionalProperties' treated as regular field in some cases #8657

@ivan-zakharchuk

Description

@ivan-zakharchuk

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on
    CodeSandbox
  • [x ] 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

After running mesh-compose on a swagger yaml with 'additionalProperties' field, in cases when it is an object, the resulting supegraph contains it as a simple object property instead of JSON:

application/json:
              schema:
                type: object
                properties:
                  "additionalPropertiesTrue":
                    type: object
                    additionalProperties: true
                  "additionalPropertiesInteger":
                    type: object
                    additionalProperties:
                      type: integer
                  "additionalPropertiesObject":
                    type: object
                    additionalProperties:
                      type: object
                      properties:
                        code:
                          type: integer
                        text:
                          type: string
                  "additionalPropertiesObjectWithCustomTitle":
                    type: object
                    additionalProperties:
                      type: object
                      properties:
                        code:
                          type: integer
                        text:
                          type: string
                      title: This is a custom title
                  "additionalPropertiesArrayInteger":
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: integer
                  "additionalPropertiesObjectRef":
                    type: object
                    additionalProperties:
                      "$ref": "#/components/schemas/ref"
                  "additionalPropertiesObjectRefNested":
                    type: object
                    additionalProperties:
                      "$ref": "#/components/schemas/ref-with-ref"

translated into

  additionalPropertiesTrue: JSON
  additionalPropertiesInteger: JSON
  additionalPropertiesObject: IvanV3Api_PetStore_QueryPostAdditionalPropertiesObject @source(
    name: "additionalPropertiesObject"
    type: "query_post_additionalPropertiesObject"
    subgraph: "V3_Petstore"
  )
  additionalPropertiesObjectWithCustomTitle: IvanV3Api_PetStore_QueryPostAdditionalPropertiesObjectWithCustomTitle @source(
    name: "additionalPropertiesObjectWithCustomTitle"
    type: "query_post_additionalPropertiesObjectWithCustomTitle"
    subgraph: "V3_Petstore"
  )
  additionalPropertiesArrayInteger: JSON
  additionalPropertiesObjectRef: JSON
  additionalPropertiesObjectRefNested: IvanV3Api_PetStore_QueryPostAdditionalPropertiesObjectRefNested @source(
    name: "additionalPropertiesObjectRefNested"
    type: "query_post_additionalPropertiesObjectRefNested"
    subgraph: "V3_Petstore"
  )

To Reproduce Steps to reproduce the behavior:

open attached sanbox and run pnpm run start

Expected behavior

all the output for response fields should have JSON type

Environment:

"@graphql-mesh/compose-cli": "^1.4.0",
"@omnigraph/openapi": "^0.109.0",

Additional context

the original testing file is from: https://github.com/readmeio/oas-examples/blob/060d4ffbbe63003f923c8cd7268ee39a495cf21f/3.0/yaml/schema-additional-properties.yaml#L18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions