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

Support for required additionalProperties in schema #1086

Open
Vasfed opened this issue Oct 25, 2019 · 3 comments
Open

Support for required additionalProperties in schema #1086

Vasfed opened this issue Oct 25, 2019 · 3 comments

Comments

@Vasfed
Copy link

Vasfed commented Oct 25, 2019

When specifying additionalProperties fields as required there's no indication of these.

Example schema:

openapi: 3.0.2
info:
  title: Test
  version: "0.0.1"
paths:
  /example:
    get:
      summary: Example operation
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    description: dynamic fields, expect to see `prop1` and `prop2` as required field names here
                    additionalProperties:
                      type: string
                  - required:
                    - prop1
                    - prop2
              example:
                prop1: required prop
                prop2: required prop
                prop3: optional prop
@m-mohr
Copy link
Contributor

m-mohr commented Oct 28, 2019

If there are two fields with a fixed name prop1 and prop2, you should probably just list them as properties.

@Vasfed
Copy link
Author

Vasfed commented Oct 28, 2019

If there are two fields with a fixed name prop1 and prop2, you should probably just list them as properties.

This workaround loses clarity for documentation reader about these fields belonging to the same entity. Also induces spec code duplication (in required for validation and in properties to show up in docs, which should be in sync). Initial usecase is producing reusable object with urls to different formats and sizes of the same single image.

More generally speaking - I think we should not silently ignore fields from required, if these are not listed in properties

@handrews
Copy link

@Vasfed that's really more of a JSON Schema issue. Those fields are being handled as designed, but there's a proposal for a combination requiredProperties field that has a fair amount of support and seems targeted for the next draft.
json-schema-org/json-schema-spec#846

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

Successfully merging a pull request may close this issue.

3 participants