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

[BUG][JAVA] Object not enforcing minProperties #20456

Open
4 of 6 tasks
oscar8880 opened this issue Jan 13, 2025 · 0 comments
Open
4 of 6 tasks

[BUG][JAVA] Object not enforcing minProperties #20456

oscar8880 opened this issue Jan 13, 2025 · 0 comments

Comments

@oscar8880
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Actual behaviour
When defining an object with minProperties like so:

RequestBody:
  type: object
  minProperties: 1
  properties:
    foo:
      type: string
      example: "abc"
    bar:
      type: integer
      example: 123

the minimum properties field is seemingly not enforced. In the above example an empty object will be accepted and generate the class

class RequestBody {
    foo: null
    bar: null
}

Expected behaviour
My expectation would be that deserialising an empty object into a RequestBody class should throw an error due to fewer than 1 minimum property being present.

openapi-generator version

7.10.0, not a regression

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Test
  version: v1
paths:
  /test:
    post:
      operationId: test
      requestBody:
        required: true
        description: Lorem ipsum
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestBody'
      responses:
        201:
          description: Lorem ipsum
          content:
            application/json:
              schema:
                type: object
                properties:
                  foo:
                    type: string

components:
  schemas:
    RequestBody:
      type: object
      minProperties: 1
      properties:
        foo:
          type: string
          example: "abc"
        bar:
          type: integer
          example: 123
Related issues/PRs

I wasn't able to find existing issues relating to this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant