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

The oas3-valid-media-example linter complains about using nullable type when using allOf. I am using the below example schema: #2620

Open
menaheme opened this issue May 8, 2024 · 1 comment
Labels
p/medium t/bug Something isn't working triaged

Comments

@menaheme
Copy link

menaheme commented May 8, 2024

The oas3-valid-media-example linter complains about using nullable type when using allOf. I am using the below example schema:

openapi: 3.0.1
info:
  title: User API
  description: The User API allows managing users.
  version: 0.1.0
paths:
  /api/v1/user:
    patch:
      summary: Patch User
      operationId: patchUser
      requestBody:
        description: Patch user body
        required: true
        content:
          application/json:
            example:
              Name: test
            schema:
              $ref: "#/components/schemas/PatchRequest"
      responses:
        "200":
          description: The patched user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Name"

components:
  schemas:
    Name:
      type: string
      description: Name of the user.
      maxLength: 255
      minLength: 1

    ID:
      type: string
      description: ID of the user.
      maxLength: 255
      minLength: 1

    PatchRequest:
      description: Patch user
      allOf:
        - $ref: "#/components/schemas/Name"
        - $ref: "#/components/schemas/ID"
      minProperties: 1
      nullable: true

Why does the linter complain while using nullable:true ? Also, when i remove the example from the spec, the error goes away. I am using this code generator https://github.com/deepmap/oapi-codegen and it generates the code as expected and works fine.

Originally posted by @sonasingh46 in #2568

@menaheme
Copy link
Author

menaheme commented May 8, 2024

found in discussions, happens to me too

@mnaumanali94 mnaumanali94 added t/bug Something isn't working p/medium labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/medium t/bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

2 participants