swagger-api / swagger-api/swagger-parser
V1 - SwaggerCompatConverter - Bad mapping in "Contact" object
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/main/java/io/swagger/parser/SwaggerCompatConverter.java around lines 554-555, where the Swagger 1.2 contact value is mapped into the OpenAPI Contact object. Verify the converted descriptor represents the email as contact.email rather than contact.url, and confirm the resulting contact URL is no longer populated with the email address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100