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

V1 - SwaggerCompatConverter - Bad mapping in "Contact" object #1451

Open
phiz71 opened this issue Oct 6, 2020 · 2 comments
Open

V1 - SwaggerCompatConverter - Bad mapping in "Contact" object #1451

phiz71 opened this issue Oct 6, 2020 · 2 comments

Comments

@phiz71
Copy link
Contributor

phiz71 commented Oct 6, 2020

Hi,
according to the 1.2 version of Swagger specs, info.contact is used for email.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/1.2.md#513-info-object

However, in the SwaggerCompatConverter, the contact field is put into url
https://github.com/swagger-api/swagger-parser/blob/v1/modules/swagger-compat-spec-parser/src/main/java/io/swagger/parser/SwaggerCompatConverter.java#L554-L555

            Contact contact = null;
            if (apiInfo.getContact() != null) {
                contact = new Contact()
                        .url(apiInfo.getContact());
            }

It should be "email".

As a consequence, when I parse this swagger descriptor in version 1.2 with OpenAPIParser:

{
  "apiVersion": "1.2.3",
  "swaggerVersion": "1.2",
  "info": {
    "title": "My title",
    "description": "My description",
    "termsOfServiceUrl": "http://swagger.io/terms/",
    "contact": "apiteam@swagger.io",
    "license": "Apache 2.0",
    "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html"
  }
...

I get this OpenAPI descriptor:

openapi: 3.0.1
info:
  title: My title
  description: My description
  termsOfService: http://swagger.io/terms/
  contact:
    url: apiteam@swagger.io
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.2.3
...

which is not valid, since info.contact.url must be in the format of a URL (https://swagger.io/specification/#contact-object)

phiz71 added a commit to phiz71/swagger-parser that referenced this issue Oct 7, 2020
Put swagger 1.2 `contact` field into swagger 2 `contact.email` field instead of url
Fixes swagger-api#1451
@phiz71
Copy link
Contributor Author

phiz71 commented Oct 9, 2020

It seems that what I propose is in conflict with LegacyConverterTest.

@phiz71
Copy link
Contributor Author

phiz71 commented Oct 9, 2020

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