Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger editor converter fails to convert nested properties from 2.0 to 3.x #4720

Open
johansenja opened this issue Jan 12, 2024 · 0 comments

Comments

@johansenja
Copy link

johansenja commented Jan 12, 2024

Q&A

Content & configuration

Example Swagger/OpenAPI definition: https://pastebin.com/dbRtCgJF (too long for GH issue otherwise)

Swagger-Editor configuration options:
Default from https://editor-next.swagger.io/ and https://editor.swagger.io/

Describe the bug you're encountering

When converting from swagger 2.0 to openApi 3.x, none of the properties of the "200" response type (apart from the basic top-level ones) are converterd - it simple gives all the top level properties (transactionDetail, inquiryDetail, blockStatus, organization) as objects with additionalProperties: true

Output
openapi: 3.0.1
info:
title: Data Blocks
description: The Data Block API is intended to vend Data Blocks to customers transactionally
  based on a request for a single DUNS.
version: "1"
servers:
- url: https://plus.dnb.com/
paths:
/v1/data/duns/{dunsNumber}:
  get:
    tags:
    - dataBlocks
    summary: Endpoint
    description: The Data Block API is intended to vend Data Blocks to customers
      transactionally based on a request for a single DUNS.
    operationId: dataBlocks
    parameters:
    - name: Authorization
      in: header
      description: The access token provided by authentication.
      required: true
      schema:
        type: string
      example: Bearer alphanumerictoken
    - name: dunsNumber
      in: path
      description: A 9-character numeric string identifying the entity by its Dun
        & Bradstreet D-U-N-S number.
      required: true
      schema:
        type: string
      example: "804735132"
    - name: blockIDs
      in: query
      description: "The block ID provided by Dun & Bradstreet that identifies the\
        \ data block to be returned.<br/><br/>Multiple values can be included, separated\
        \ by commas."
      required: true
      schema:
        type: string
      example: blockID
    - name: tradeUp
      in: query
      description: "Indicates if the Headquarters D-U-N-S Number should be returned\
        \ if a Branch is requested.<br/><br/>Valid values:<br/>* hq: If the provided\
        \ D-U-N-S Number is a Branch, the Headquarter D-U-N-S Number is returned.<br/>*\
        \ domhq: If the provided D-U-N-S Number is a Branch, the Domestic Headquarter\
        \ D-U-N-S Number is returned.<br/><br/>If the requested D-U-N-S Number is\
        \ not a Branch, that D-U-N-S Number will be returned regardless of the value\
        \ of this parameter.<br/><br/>If the parameter is omitted, the requested\
        \ D-U-N-S Number is returned even if it is a Branch."
      schema:
        type: string
      example: hq
    - name: customerReference
      in: query
      description: Up to 240 characters for a reference string to be linked to the
        request in order to support subsequent order reconciliation.
      schema:
        type: string
      example: customer reference text
    responses:
      "200":
        description: OK
        content:
          application/json;charset=utf-8:
            schema:
              type: object
              properties:
                transactionDetail:
                  type: object
                  additionalProperties: true
                  description: The information used to process this request.
                inquiryDetail:
                  type: object
                  additionalProperties: true
                  description: The criteria used to process this request.
                blockStatus:
                  type: array
                  description: Records the status of the data blocks requested by
                    the customer.
                  items:
                    type: object
                    additionalProperties: true
                organization:
                  type: object
                  additionalProperties: true
                  description: The details of the entity.
              description: ""
      "301":
        description: Moved Permanently
        headers:
          location:
            description: The URL to retrieve the D-U-N-S Number to which the requested
              D-U-N-S Number was transferred.
            schema:
              type: string
        content:
          application/json;charset=utf-8:
            schema:
              type: object
              description: ""
    security: []
    x-monitoring: "Available except \"Business Activity Insights\", \"Derived Trade\
      \ Insights\", \"Inquiry Insights\", \"Company Information Advanced Geoposition\
      \ Side Block\", \"Hierarchies & Connections ELI Side Block\". Please refer\
      \ <a href=\"/html/guides/Monitor/DataProducts.html\" target=\"_blank\">guide</a>\
      \ for details."
    x-monitoring-pdf: "Available except \"Business Activity Insights\", \"Derived\
      \ Trade Insights\", \"Inquiry Insights\", \"Company Information Advanced Geoposition\
      \ Side Block\", \"Hierarchies & Connections ELI Side Block\". Please refer\
      \ guide for details."
  x-DNB-Name: "Data Blocks (companyinfo_L1_v1, hierarchyconnections_L1_v1)"
  x-DNB-ID: dataBlocks
components: {}
x-original-swagger-version: "2.0"
To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor-next.swagger.io/ or https://editor.swagger.io/ (behaviour is the same)
  2. Paste the sample from above
  3. Click on Edit > Convert to OpenAPI 3.x
  4. See output (most of the properties are gone)

Expected behavior

The converter converts all properties - or at least gives an error/feedback if the schema is incorrect (though it seems to parse and display the properties OK from the 2.0 version, which suggests that the input is valid

Screenshot 2024-01-12 at 10 42 32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant