openBackhaul / AirInterfacePowerSaver

Pranay's first Application on the MW SDN Controller
Apache License 2.0
1 stars 1 forks source link

additionalProperties:false property to be added for the requestBody schema with description "document measure for resolving a potentially undefined state" of service /v1/record-power-saving-status #70

Closed vanithavalluripalli9 closed 4 months ago

vanithavalluripalli9 commented 7 months ago

Currently in OAS, the requestBody schema for service /v1/record-power-saving-status is defined as below

requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - description: 'add deviation to a power saving status entry'
                  type: object
                  required:
                    - link-id
                    - add-deviation-from-original-state
                    - add-module-to-restore-original-state
                - description: 'remove deviation from a power saving status entry'
                  type: object
                  required:
                    - link-id
                    - remove-deviation-from-original-state
                    - remove-module-to-restore-original-state
                - description: 'document measure for resolving a potentially undefined state'
                  type: object
                  required:
                    - link-id
                    - add-module-to-restore-original-state 

where both the schemas with description

Problem :

As per the definition of oneOf a “request body is not valid if it matches both schemas” So , if you provide a requestBody that matches the schema with description add deviation to a power saving status entry, then express framework will match it to both the subschemas and marks this request as invalid.

Reference : https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/#difference Proposal: For service /v1/record-power-saving-status , requesting to add additionalProperties:false to the requestBody schema with description document measure for resolving a potentially undefined state properties as mentioned below which will resolve the issue.

 requestBody:
    required: true
    content:
      application/json:
        schema:
          oneOf:
            - description: 'add deviation to a power saving status entry'
              type: object
              required:
                - link-id
                - add-deviation-from-original-state
                - add-module-to-restore-original-state
            - description: 'remove deviation from a power saving status entry'
              type: object
              required:
                - link-id
                - remove-deviation-from-original-state
                - remove-module-to-restore-original-state
            - description: 'document measure for resolving a potentially undefined state'
              type: object
              required:
                - link-id
                - add-module-to-restore-original-state
              additionalProperties: false
              properties: