Skip to content

Generator ignores nullability #178

Open
@xperiandri

Description

@xperiandri
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

Activity

xperiandri

xperiandri commented on Jan 31, 2021

@xperiandri
ContributorAuthor

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

sergey-tihon

sergey-tihon commented on Jan 31, 2021

@sergey-tihon
Member

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

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

xperiandri

xperiandri commented on Jan 31, 2021

@xperiandri
ContributorAuthor

image

nullable: false

sergey-tihon

sergey-tihon commented on Jan 31, 2021

@sergey-tihon
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

Numpsy commented on Apr 13, 2021

@Numpsy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Numpsy@sergey-tihon@xperiandri

        Issue actions

          Generator ignores nullability · Issue #178 · fsprojects/SwaggerProvider