Skip to content

Conversation

@quilicicf
Copy link
Contributor

@quilicicf quilicicf commented Jan 11, 2018

Impacted version

v2.0.0-rc2

Issue description

When using OpenAPIDeserializer to deserialize security schemes with type: apiKey and in: cookie, the value of in is null in the generated OpenAPI object.

Simplest reproduction scenario

OAS 3 definition:

openapi: 3.0.0
servers:
  - url: 'https://whatever.net/v1'
info:
  description: ''
  version: 1.0.0
  title: Demo for cookie apiKey
paths: {}
components:
  securitySchemes:
    API_KEY:
      type: apiKey
      description: The API key
      name: auth
      in: cookie

Test code:

import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.parser.core.models.SwaggerParseResult;
import org.testng.annotations.Test;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;

import static org.testng.Assert.assertEquals;

public class ApiKeyCookieTest {

    @Test
    public void test() throws Exception {
        final Path oas3Path = Paths.get("/tmp/apiKeyCookie.yml"); // TODO: <=== change the path to fit your environment
        final JsonNode jsonNode = Yaml.mapper().readTree(oas3Path.toFile());
        final SwaggerParseResult parseResult = new OpenAPIDeserializer().deserialize(jsonNode);

        final Map<String, SecurityScheme> securitySchemes = parseResult.getOpenAPI().getComponents().getSecuritySchemes();
        assertEquals(securitySchemes.get("API_KEY").getIn(), SecurityScheme.In.COOKIE);
    }
}

Additional notes

I've taken the liberty to change the tests by I'm not sure how you want to test that exactly.
Just tell me if you'd like it done elseways.

Copy link
Contributor

@gracekarina gracekarina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quilicicf Thanks for the fix, I think the tests are ok.

@gracekarina gracekarina merged commit ea3d577 into swagger-api:2.0 Jan 16, 2018
@quilicicf quilicicf deleted the 2.0_fixSecurityDeserializationIssues branch January 22, 2018 13:37
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

Successfully merging this pull request may close these issues.

2 participants