Skip to content

Server Response Does Not Match OpenAPI Schema for ItemsPageObject #688

@bncszb

Description

@bncszb

I tried to create a python client using OpenApi Generator, but I ran into some discrepancies.

The server responses for the ItemsPageObject schema do not conform to the declared OpenAPI specification. According to the OpenAPI documentation at https://snowstorm.snomedtools.org/snowstorm/snomed-ct/v3/api-docs/snowstorm, the items and searchAfterArray properties are defined as arrays of objects:

{
"ItemsPageObject": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "total": {
            "type": "integer",
            "format": "int64"
          },
          "limit": {
            "type": "integer",
            "format": "int64"
          },
          "offset": {
            "type": "integer",
            "format": "int64"
          },
          "searchAfter": {
            "type": "string"
          },
          "searchAfterArray": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
}

However, the actual server responses ma contain arrays of primitive values (e.g., strings or numbers) instead of objects. This discrepancy causes validation and deserialization errors when using generated clients (such as those from OpenAPI Generator for Python), which expect a list of dictionaries but receive a list of primitives.

Expected Behavior

The server should return data that matches the OpenAPI schema, specifically:

  • items and searchAfterArray should be arrays of objects (JSON objects/dictionaries).

Example:

{
  "items": [ { "id": 1 }, { "id": 2 } ],
  "searchAfterArray": [ { "token": "abc" } ]
}

Actual Behavior

The server is returning arrays of primitive values instead of objects.

Example:

{
  "items": [ "foo", "bar", "baz" ],
  "searchAfterArray": [ 1, 2, 3 ]
}

Impact

  • Generated clients fail with validation or deserialization errors.
  • Automated tooling and type checking break due to the schema mismatch.
  • Consumers of the API must implement workarounds or bypass validation, reducing reliability and maintainability.

Steps to Reproduce

  1. Use the OpenAPI documentation to generate a Python client.
    docker run --rm -v "${PWD}:/local/out/python" openapitools/openapi-generator-cli generate \
        -i https://snowstorm.snomedtools.org/snowstorm/snomed-ct \
        -g python \
        -o /local/out/python \
        --package-name {{PACKAGE_NAME}} \
        --artifact-version {{PACKAGE_VERSION}} \
        --git-user-id {{GIT_USER_NAME}} \
        --git-repo-id {{GIT_REPO_ID}} \
        --library urllib3 \
        --additional-properties=packageUrl=https://github.com/{{GIT_USER_NAME}}/{{GIT_REPO_ID}},packageVersion={{PACKAGE_VERSION}},projectName={{PACKAGE_NAME}},packageCompany="{{AUTHOR_NAME}}",authorName="{{AUTHOR_NAME}}",authorEmail="{{AUTHOR_EMAIL}}",packageDescription="Python client for SNOMED CT Snowstorm API"
  1. Call an endpoint returning an ItemsPageObject.
from snowstorm_client import ApiClient, ConceptsApi, Configuration

config = Configuration(
    host="https://snowstorm.snomedtools.org/snowstorm/snomed-ct",
)

api_client = ApiClient(config)

api_client.user_agent = "urllib3/2.0.4"

ecl = """< 64572001 |Disease (disorder)| : {
  116676008 |Associated morphology| = << 87642003 |Dislocation|,
  363698007 |Finding site| = << 85537004 |Glenohumeral joint structure|
}"""

concepts = client.find_concepts(
    branch="MAIN",
    active_filter=True,
    term_active=True,
    language=["en"],
    include_leaf_flag=False,
    ecl=ecl,
    limit=1,
    return_id_only=False,
)

print(concepts)

Suggested Solutions

  • Update the server implementation to ensure that items and searchAfterArray always return arrays of objects, as specified.
  • OR: Update the OpenAPI schema to reflect the actual data structure (e.g., set items: {} to allow any type).
  • OR: Add a note in the documentation about the discrepancy and recommended client workarounds.

Thank you for your attention to this issue! Please let me know if more information is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions