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] Core java schema classes missing schema required property names + requiredVars values #8906

Closed
6 tasks
spacether opened this issue Mar 5, 2021 · 2 comments · Fixed by #13117
Closed
6 tasks

Comments

@spacether
Copy link
Contributor

spacether commented Mar 5, 2021

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

Core classes that store schemas:

  • CodegenModel
  • CodegenProperty
  • CodegenParameter
  • CodegenResponse

are missing schema.required information which is a list of strings
At first glance it looks like requiredVars may contain this info but that's not true
That only stores properties whose names are in required.
So if a property is an additionalProperty (not defined in properties) then it does not make it into requiredVars
@wing328
@jimschubert
@cbornet
@ackintosh
@jmini
@etherealjoy
@sebastien-rosset

Feature: jsonschema.required

openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Add requiredPropertyNames to:

  • CodegenModel
  • CodegenProperty
  • CodegenParameter
  • CodegenResponse
@spacether spacether changed the title [BUG] CodegenModel/CodegenProperty/CodegenParameter/CodegenResponse missing schema required [BUG] Core java schema classes are missing schema required property names Mar 5, 2021
@spacether spacether changed the title [BUG] Core java schema classes are missing schema required property names [BUG] Core java schema classes missing schema required property names + requiredVars Mar 12, 2021
@spacether spacether changed the title [BUG] Core java schema classes missing schema required property names + requiredVars [BUG] Core java schema classes missing schema required property names + requiredVars values Mar 12, 2021
@spacether
Copy link
Contributor Author

This PR: #8962
adds a hasRequired boolean and adds tests showing that this data is missing from many of our java schema classes.

@spacether
Copy link
Contributor Author

spacether commented Jun 29, 2022

This issue came up when working on #12619
The codegenModel for the component RequiredWithEscapedCharacters in the schema below:

openapi: 3.0.3
info:
  title: openapi 3.0.3 sample spec
  description: sample spec for testing openapi functionality, built from json schema
    tests for draft6
  version: 0.0.1
paths: {}
components:
  schemas:
    RequiredWithEscapedCharacters:
      required:
      - 'foo

        bar'
      - foo"bar
      - foo\bar
      - "foo\rbar"
      - "foo\tbar"
      - "foo\fbar"

Does not have any requiredVars generated for it.

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

Successfully merging a pull request may close this issue.

1 participant