Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Generated OpenAPI missing discriminator #36

@PatrickChenHZ

Description

@PatrickChenHZ

Hello,

When I make a device discovery request through generated python api, I get the following:

ERROR:api.fl_printer:Formlabs Printer Init {redacted SN}, Failed to be discovered by FL Server, Multiple matches found when deserializing the JSON string into DeviceStatusModel with oneOf schemas: FleetControlPrinterGroupDeviceStatusModel, Form2DeviceStatusModel, Form3FamilyDeviceStatusModel, Form4FamilyDeviceStatusModel, Fuse1DeviceStatusModel, GenericDeviceStatusModel. Details: 6 validation errors for FleetControlPrinterGroupDeviceStatusModel

Making POST request manually seems to work fine, just look like a deserialzier error. It seems to me the spec is missing discriminator here and there for oneof fields.

{
    "count": 1,
    "devices": [
        {
            "cartridge_data": {
                "NONE": {
                    "cartridgeEstimatedVolumeDispensed_mL": 0,
                    "cartridgeMaterialCode": "NONE",
                    "cartridgeOriginalVolume_mL": 0
                }
            },
            "connection_type": "ETHERNET",
            "estimated_print_time_remaining_ms": 0,
            "firmware_version": "2.5.4-2654",
            "form_auto_status": "",
            "id": "JasperKestrel",
            "ip_address": "192.168.150.114",
            "is_connected": true,
            "is_remote_print_enabled": true,
            "product_name": "Form 3+",
            "ready_to_print_now": false,
            "status": "Idle",
            "tank_id": "NONE",
            "tank_material_code": "NONE"
        }
    ]
}

Here is my call to the openFL API:

self.server_port = instance.port
      self.server_client.configuration.host = "http://localhost:" + str(self.server_port)
      logger.info(f"Formlabs Printer Init {self.serial_number}, locked on FL Server Instance on Port {self.server_port}")
try:
     device_api = api_client.DevicesApi(self.server_client)
     response = device_api.discover_devices_with_http_info(api_client.DiscoverDevicesRequest(timeout_seconds=20, ip_address=self.ip))
     logger.debug(response)
     if isinstance(response, api_client.DiscoverDevices200Response):
              logger.info(f"Formlabs Printer Init {self.serial_number}, FL Server Discover Test Passed")
except Exception as e:
     logger.error(f"Formlabs Printer Init {self.serial_number}, Failed to be discovered by FL Server, {e}")

Am I doing something wrong, or is the spec a little broken. And is formlabs accepting pull requests or plan on fixing the spec? I know the repo actually discourage the use of the full API module, but it will be nice if it does work.

Thank you

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

    Issue actions