Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kevbook opened this issue Aug 19, 2024 · 0 comments
Open

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

kevbook opened this issue Aug 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@kevbook
Copy link

kevbook commented Aug 19, 2024

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

@kevbook kevbook added the bug Something isn't working label Aug 19, 2024
@kevbook kevbook changed the title In the OpenAPI spec, enum key exists are not respected In the OpenAPI spec, enum keys are not respected Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant