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

Generator ignores nullability #178

Open
xperiandri opened this issue Jan 31, 2021 · 5 comments
Open

Generator ignores nullability #178

xperiandri opened this issue Jan 31, 2021 · 5 comments

Comments

@xperiandri
Copy link
Contributor

Description

    Service:
      type: object
      properties:
        Услуга:
          type: string
        Стоимость:
          type: number
          format: 
          nullable: false
        Обязательная:
          type: boolean
          nullable: false

Expected behavior

Properties of value type marked as nullable: false declared as non-nullable and has a non-nullable parameter in a constructor

Actual behavior

nullable: false is ignored

Related information

1.0.0-Beta1

@xperiandri
Copy link
Contributor Author

xperiandri commented Jan 31, 2021

@sergey-tihon, please, point me where to apply fix I will code that today

@sergey-tihon
Copy link
Member

Sorry, I do not understand what is the issue...

Here is the property generation code for OpenApiProvider and here for SwaggerProvider.

@xperiandri
Copy link
Contributor Author

image

nullable: false

@sergey-tihon
Copy link
Member

Here is the line where we determine if the property is optional.
https://github.com/fsprojects/SwaggerProvider/blob/net5/src/SwaggerProvider.DesignTime/v3/DefinitionCompiler.fs#L202

Is easiest way to debug is to put breakpoint on this line and check how Microsoft.OpenApi.Readers passed your schema.

@Numpsy
Copy link

Numpsy commented Apr 13, 2021

Could that be because the fields aren't marked as required in the schema, so the generated properties have to be optional to handle them not being present in the Json data?

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

3 participants