Skip to content

Open Api errors with openapi-typescript #21

@hannahbultra

Description

@hannahbultra

Hi, I wanted to generate types from the provided yaml using openapi-typescript with this command:
openapi-typescript node_modules/shipengine-openapi/openapi.yaml --output src/types/ShipEngineTypes.ts

However, three types seem to have an issue, though not sure on the exact cause

  • pickup_response_body
  • get_rate_by_id_response_body
  • update_shipment_response_body

type and error for update_shipment_response_body

update_shipment_response_body: WithRequired<components["schemas"]["create_and_validate_shipment"], "errors" | "has_errors" | "address_validation" | "shipment_id" | "carrier_id" | "service_code" | "ship_date" | "created_at" | "shipment_status" | "ship_to" | "ship_from" | "return_to" | "confirmation" | "customs" | "advanced_options" | "insurance_provider" | "tags" | "packages" | "total_weight">;

Type '"created_at" | "ship_date" | "shipment_id" | "carrier_id" | "service_code" | "shipment_status" | "ship_to" | "ship_from" | "return_to" | "confirmation" | "customs" | "advanced_options" | ... 6 more ... | "address_validation"' does not satisfy the constraint '"created_at" | "modified_at" | "ship_date" | "shipment_id" | "carrier_id" | "service_code" | "shipment_status" | "ship_to" | "ship_from" | "warehouse_id" | "return_to" | "confirmation" | ... 15 more ... | "address_validation"'.
  Type '"has_errors"' is not assignable to type '"created_at" | "modified_at" | "ship_date" | "shipment_id" | "carrier_id" | "service_code" | "shipment_status" | "ship_to" | "ship_from" | "warehouse_id" | "return_to" | "confirmation" | ... 15 more ... | "address_validation"'.ts(2344)

type and error for get_rate_by_id_response_body

get_rate_by_id_response_body: WithRequired<components["schemas"]["rate"], "rates" | "invalid_rates" | "rate_request_id" | "shipment_id" | "created_at" | "status" | "errors">;

Type '"shipment_id" | "created_at" | "errors" | "rates" | "invalid_rates" | "rate_request_id" | "status"' does not satisfy the constraint '"carrier_id" | "service_code" | "ship_date" | "carrier_code" | "estimated_delivery_date" | "package_type" | "requested_comparison_amount" | "trackable" | "rate_type" | "validation_status" | ... 15 more ... | "error_messages"'.
  Type '"shipment_id"' is not assignable to type '"carrier_id" | "service_code" | "ship_date" | "carrier_code" | "estimated_delivery_date" | "package_type" | "requested_comparison_amount" | "trackable" | "rate_type" | "validation_status" | ... 15 more ... | "error_messages"'.ts(2344)

I thought it could be an issue with required fields, for example from the yaml:

    get_rate_by_id_response_body:
      title: get_rate_by_id_response_body
      type: object
      description: A rate response body
      required:
        - rates
        - invalid_rates
        - rate_request_id
        - shipment_id
        - created_at
        - status
        - errors

in this case I'm not sure if rates should be required for Get Rate By Id which should only be returning one rate based on https://shipengine.github.io/shipengine-openapi/#operation/get_rate_by_id

or in the case of pickup_response_body, pickup is required in addition to all the properties of "pickup" such as pickup_id

pickup_response_body:
      title: pickup_response_body
      type: object
      description: A pickup response body
      required:
        - pickup
        - pickup_id
        - label_ids
        - created_at
        - carrier_id
        - warehouse_id
        - pickup_address
        - contact_details
        - notes
        - pickup_window
        - confirmation_number
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/pickup'

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