Skip to content

Python Build Issues #7835

Open
Open
@Bobspadger

Description

@Bobspadger
Description

Attempting to create a python module for using the Royal Mail rest API.
Swagger output the module, and pip install . works fine.

Importing the newly created module results in

ImportError: No module named 'rm_tracking.models.inline_response200_error'

Which is because the path should be:
rm_tracking.models.inline_response_200_error

Swagger-codegen version

2.3.1

Swagger declaration file content or url
---
swagger: "2.0"
info:
  title: Tracking API (REST)
  description: "Tracking API provides the functionality to enquire on the tracking
    status of mail items. The API provides the latest tracking information, the tracking
    history, and the proof of delivery information (minus the signature image) for
    a single mail item. The API provides an alternative mechanism to using the track
    and trace function on the Royal Mail website (http://www.royalmail.com/track-trace).
    \n \nThere are no costs to customers for using the Tracking API services, however
    development costs must be covered by the customer. Royal Mail will not accept
    any responsibility for these development, implementation and testing costs.\n
    \nCustomers should address initial inquiries regarding development of systems
    for these purposes to their account handler."
  version: 1.0.0-live
  x-ibm-name: tracking-api-rest
basePath: /mailPieces
schemes:
- https
x-ibm-configuration:
  enforced: true
  phase: realized
  testable: true
  externalDocs: []
tags: []
securityDefinitions:
  Client ID:
    description: ""
    in: header
    name: X-IBM-Client-Id
    type: apiKey
  Client Secret:
    type: apiKey
    name: X-IBM-Client-Secret
    in: header
    description: ""
paths:
  /{trackingNumber}/proofOfDelivery:
    get:
      description: Provides the details captured at the point of delivery as proof
        that delivery has occurred. Note that a proof of delivery is only captured
        by the delivery track for those service offerings that require a signature
        on delivery. Please also note that for data protection reasons the API does
        not currently supply the signature image captured at the point of delivery.
      tags: []
      parameters:
      - name: trackingNumber
        type: string
        required: true
        in: path
        description: ""
      responses:
        200:
          schema:
            type: object
            properties:
              proofOfDelivery:
                type: array
                items:
                  type: object
                  properties:
                    trackingNumber:
                      type: string
                    height:
                      type: string
                    width:
                      type: string
                    image:
                      type: string
                    printedName:
                      type: string
                    signatureTime:
                      type: string
              error:
                type: object
                properties:
                  code:
                    type: string
                  description:
                    type: string
                  cause:
                    type: string
                  resolution:
                    type: string
                  context:
                    type: string
          description: Tracking Proof of Delivery
          examples:
            application/json:
              proofOfDelivery:
              - trackingNumber: ""
                height: ""
                width: ""
                image: ""
                printedName: ""
                signatureTime: ""
              error:
                code: ""
                description: ""
                cause: ""
                resolution: ""
                context: ""
        500:
          description: General error
          headers: []
          examples:
            application/json:
              httpCode: "500"
              httpMessage: Bad Request
              moreInformation: ""
          schema:
            type: object
            properties:
              httpCode:
                type: string
              httpMessage:
                type: string
              moreInformation:
                type: string
      security:
      - Client ID: []
        Client Secret: []
      summary: Get Proof of Delivery
  /{trackingNumber}/history:
    get:
      description: Provides the tracking history for a single mail item.
      tags: []
      parameters:
      - name: trackingNumber
        type: string
        required: true
        in: path
        description: ""
      responses:
        200:
          schema:
            type: object
            properties:
              trackDetail:
                type: array
                items:
                  type: object
                  properties:
                    trackingNumber:
                      type: string
                    trackDate:
                      type: string
                    trackPoint:
                      type: string
                    trackTime:
                      type: string
                    status:
                      type: string
                    messages:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            type: string
                          detail:
                            type: string
                    podMessage:
                      type: string
              error:
                type: object
                properties:
                  code:
                    type: string
                  description:
                    type: string
                  cause:
                    type: string
                  resolution:
                    type: string
                  context:
                    type: string
          description: Tracking Details
          examples:
            application/json:
              trackDetail:
              - trackingNumber: ""
                trackDate: ""
                trackPoint: ""
                trackTime: ""
                status: ""
                messages:
                - id: ""
                  detail: ""
                podMessage: ""
              error:
                code: ""
                description: ""
                cause: ""
                resolution: ""
                context: ""
        500:
          description: General Error
          headers: []
          examples:
            application/json:
              httpCode: "500"
              httpMessage: Bad Request
              moreInformation: ""
          schema:
            type: object
            properties:
              httpCode:
                type: string
              httpMessage:
                type: string
              moreInformation:
                type: string
      security:
      - Client ID: []
        Client Secret: []
      summary: Get Single Item History
  /{trackingNumber}/summary:
    get:
      description: Provides the latest tracking event for a single mail item.
      tags: []
      parameters:
      - name: trackingNumber
        type: string
        required: true
        in: path
        description: ""
      responses:
        200:
          schema:
            type: object
            properties:
              trackSummary:
                type: object
                properties:
                  trackingNumber:
                    type: string
                  eventDate:
                    type: string
                  eventTime:
                    type: string
                  statusCode:
                    type: string
                  summaryLine:
                    type: string
                  status:
                    type: string
                  messages:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        detail:
                          type: string
              errors:
                type: array
                items:
                  type: object
                  properties:
                    code:
                      type: string
                    description:
                      type: string
                    cause:
                      type: string
                    resolution:
                      type: string
                    context:
                      type: string
          description: Tracking summary
          examples:
            application/json:
              trackSummary:
                trackingNumber: ""
                eventDate: ""
                eventTime: ""
                statusCode: ""
                summaryLine: ""
                status: ""
                messages:
                - id: ""
                  detail: ""
              errors:
              - code: ""
                description: ""
                cause: ""
                resolution: ""
                context: ""
        500:
          description: ""
          headers: []
          examples:
            application/json:
              httpCode: "500"
              httpMessage: Bad Request
              moreInformation: ""
          schema:
            type: object
            properties:
              httpCode:
                type: string
              httpMessage:
                type: string
              moreInformation:
                type: string
      security:
      - Client ID: []
        Client Secret: []
      summary: Get Single Item Summary
security:
- Client ID: []
  Client Secret: []
x-ibm-endpoints:
- endpointUrl: https://api.royalmail.net
  description: Custom API Endpoint
  type:
  - production
  - development
...

Config.json

{
  "packageName": "rm_tracking",
  "projectName": "rm-tracking-api"
}
Command line used for generation

swagger-codegen generate -i Tracking_Swagger.yaml -l python -c config.json -o swagger

this outputs to /swagger

Steps to reproduce
  • create a new directory
  • cd new_directory
  • place Tracking_Swagger.yml file here
  • place config.json here
  • make a subdirectory called swagger
  • swagger-codegen generate -i Tracking_Swagger.yaml -l python -c config.json -o swagger
  • cd swagger
  • pip3 install .

Then in python:

  • import rm_tracked

This will fail due to incorrect path to InlineResponse200Error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions