Swagger editor converter fails to convert nested properties from 2.0 to 3.x
Q&A
- OS: macOS
- Browser: Firefox 120.0b8
- Version: N/A
- Method of installation: N/A
- Swagger-Editor version: The version currently [2024-01-12] on https://editor-next.swagger.io/ and https://editor.swagger.io/
- Swagger/OpenAPI version: 2.0 to 3.x
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:
- Go to https://editor-next.swagger.io/ or https://editor.swagger.io/ (behaviour is the same)
- Paste the sample from above
- Click on Edit > Convert to OpenAPI 3.x
- 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
Facing the same issue. Was any solution or alternative given for this issue?
Hmm, sorry I can't remember how I resolved this in the end - possibly by manually extracting some of the nested properties to a new schema and running the converter again. But can't be certain!
We’ve released Swagger Editor v5! 🎉 Check out the details here: Inside the New Swagger Editor. We’re closing old issues related to previous versions. If you think any of them are still relevant, please open a new issue – this helps us prioritize what matters most. Thanks for your activity! 🚀