swagger-api / swagger-api/swagger-codegen

Python Build Issues

Open
#7,835 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Python Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using Tracking_Swagger.yaml, config.json, and the documented swagger-codegen command, then inspect the generated /swagger package and its rm_tracking.models imports. Compare the generated reference to the available InlineResponse200Error module path. Done means pip install . succeeds and importing the generated client no longer requests the incorrect inline_response200_error path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.