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

Generates all required parameters #99

Open
gbloggs opened this issue Sep 29, 2024 · 1 comment
Open

Generates all required parameters #99

gbloggs opened this issue Sep 29, 2024 · 1 comment

Comments

@gbloggs
Copy link

gbloggs commented Sep 29, 2024

Describe the bug
When using 8.1 against openapi-generator-maven-plugin 7.8.0, all parameters of an object are generated as required.

Expected behavior
When an object has say one required parameter, all parameters are generated as required, not just the one defined in the swagger

To Reproduce

    Business:
      type: object
      additionalProperties: false
      properties:
        id:
          $ref: '#/components/schemas/uuid'
        businessName:
          type: string
          pattern: '^[\w\d\s]*$'
          maxLength: 128
          example: Ogurets
        vatNumber:
          type: string
          pattern: '^[\w\d\s]*$'
          maxLength: 20
          example: GB999 9999 73
        companyNumber:
          type: string
          pattern: '^[\w\d\s]*$'
          maxLength: 20
          example: '9012345678'
        headOfficeAddress:
          $ref: '#/components/schemas/Address'
        logoUrl:
          $ref: '#/components/schemas/urlString'
      required:
        - businessName

versioin 8.1 generates against openapi-generator-maven-plugin 7.8.0:

// This file is generated by https://github.com/dart-ogurets/dart-openapi-maven - you should not modify it
// log generation bugs on Github, as part of the license, you must not remove these headers from the Mustache templates.
// this project is maintained as part of FeatureHub - please consider sponsoring us at https://github.com/featurehub-io

// Business
class Business {
    
      String id;
    
      String businessName;
    
      String vatNumber;
    
      String companyNumber;
    
      Address headOfficeAddress;
    
      String logoUrl;
   

  // id required: true nullable: false default:  inherited: false container false
  // businessName required: true nullable: false default:  inherited: false container false
  // vatNumber required: true nullable: false default:  inherited: false container false
  // companyNumber required: true nullable: false default:  inherited: false container false
  // headOfficeAddress required: true nullable: false default:  inherited: false container false
  // logoUrl required: true nullable: false default:  inherited: false container false
Business(
{
    required 
      this.id
    , 
        required 
      this.businessName
    , 
        required 
      this.vatNumber
    , 
        required 
      this.companyNumber
    , 
        required 
      this.headOfficeAddress
    , 
        required 
      this.logoUrl
   
     }
)

Whereas version 7.2 against openapi-generator-maven-plugin 7.8.0:

// This file is generated by https://github.com/dart-ogurets/dart-openapi-maven - you should not modify it
// log generation bugs on Github, as part of the license, you must not remove these headers from the Mustache templates.
// this project is maintained as part of FeatureHub - please consider sponsoring us at https://github.com/featurehub-io

// Business
class Business {
    
      String? id;
    
      String businessName;
    
      String? vatNumber;
    
      String? companyNumber;
    
      Address? headOfficeAddress;
    
      String? logoUrl;

Business(
{
    
    
    
        this.id
    , 
        required 
      this.businessName
    , 
        
    
    
        this.vatNumber
    ,                    
    
        this.companyNumber
    , 
        
    
    
        this.headOfficeAddress
    , 
        
    
    
        this.logoUrl
     }
);

Versions
We only support bug fixes on the latest version of this plugin, please
confirm which version you are using?
openapi-dart-generator 8.1
openapi-generator-maven-plugin 7.8.0,

Additional context
Add any other context about the problem here.

@rvowles
Copy link
Member

rvowles commented Sep 30, 2024

This is deliberate (and in the README). The default nullability for openApi fields is nullable: false - so the new version reflects the correct definition as specified in the API document. required reflects serialization not nullability. I would recommend you make the fields nullable or give them a default value.

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

No branches or pull requests

2 participants