Skip to content

In the OpenAPI spec, enum keys are not respected #60

@kevbook

Description

@kevbook

Description

In the OpenAPI spec, when an enum key exists, it's not respected in mock responses. See example:

"responses": {
  "200": {
    "description": "Default Response",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "status": {
              "type": "number",
              "enum": [200]
            }
          },
          "required": ["status"],
          "additionalProperties": false
        }
      }
    }
  }
}

Just using standard library

import { fromOpenApi } from '@mswjs/source/open-api'
import api from './api.spec.json'
 
const handlers = await fromOpenApi(api)

// Result when using client
Result: { status: 16.76 }

Reproduction steps

Expected behavior

Initial assessment

Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions