Skip to content

field 'id' has type 'null' (expected type 'string') #1544

@ePaul

Description

@ePaul

In Zalando's internal installation, currently some APIs show a violation of rule 174 with message field 'id' has type 'null' (expected type 'string'), even though that field is clearly defined with type string.

Reproduce

https://sunrise.zalando.net/apis/linter/e2853ed1-13f9-43cd-9d3a-7a4b91f69eb2 (internal link)

openapi: 3.1.0
info:
  title: Example API
  version: 0.0.1
  description: API for demonstrating a bug in Zally
  contact:
    name: Paul
    email: [email protected]
    url: https://sunrise.zalando.net/catalog/default/user/pebermann
  x-audience: component-internal
  x-api-id: 6541f0da-be1e-11f0-869d-db2cffae9c53
paths:
  '/example/{id}':
    get:
      summary: Get example by ID
      description: Retrieve a specific example by its ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Ruleset ID
      responses:
        '200':
          description: Example details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Example'
        '404':
          description: Example not found
          content:
            application/problem+json:
              schema:
                $ref: >-
                  https://opensource.zalando.com/restful-api-guidelines/models/problem-1.0.1.yaml#/Problem
      security:
        - BearerAuth:
            - uid
components:
  schemas:
    Example:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          description: Unique identifier for the example
      example:
        id: 5a99402e-be1f-11f0-9526-83b9f772e53b

  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

Result:

Use common field names
Rule: #174
field 'id' has type 'null' (expected type 'string')

Locations:

/components/schemas/Example/properties/id
/paths/1example1{id}/get/responses/200/content/application~1json/schema/properties/id

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions