use of io.swagger.v3.oas.models.security.SecurityScheme.In in project swagger-core by swagger-api.
the class ReaderTest method testParameterWithRef.
@Test(description = "Parameter with ref")
public void testParameterWithRef() {
Components components = new Components();
components.addParameters("id", new Parameter().description("Id Description").schema(new IntegerSchema()).in(ParameterIn.QUERY.toString()).example(1).required(true));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefParameterResource.class);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /:\n" + " get:\n" + " summary: Simple get operation\n" + " description: Defines a simple get operation with a payload complex input object\n" + " operationId: sendPayload\n" + " parameters:\n" + " - $ref: '#/components/parameters/id'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " deprecated: true\n" + "components:\n" + " parameters: \n" + " id:\n" + " in: query\n" + " description: Id Description\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " example: 1\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project swagger-core by swagger-api.
the class ReaderTest method testSecuritySchemeWithRef.
@Test(description = "SecurityScheme with REf")
public void testSecuritySchemeWithRef() {
Components components = new Components();
components.addSecuritySchemes("Security", new SecurityScheme().description("Security Example").name("Security").type(SecurityScheme.Type.OAUTH2).$ref("myOauth2Security").in(SecurityScheme.In.HEADER));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefSecurityResource.class);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /:\n" + " get:\n" + " description: description\n" + " operationId: Operation Id\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " security:\n" + " - security_key:\n" + " - write:pets\n" + " - read:pets\n" + "components:\n" + " securitySchemes:\n" + " Security:\n" + " type: oauth2\n" + " description: Security Example\n" + " myOauth2Security:\n" + " type: oauth2\n" + " description: myOauthSecurity Description\n" + " $ref: '#/components/securitySchemes/Security'\n" + " in: header\n" + " flows:\n" + " implicit:\n" + " authorizationUrl: http://x.com\n" + " scopes:\n" + " write:pets: modify pets in your account\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project swagger-core by swagger-api.
the class ReaderTest method testTicket3587.
@Test(description = "Parameter examples ordering")
public void testTicket3587() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket3587Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /test/test:\n" + " get:\n" + " operationId: parameterExamplesOrderingTest\n" + " parameters:\n" + " - in: query\n" + " schema:\n" + " type: string\n" + " examples:\n" + " Example One:\n" + " description: Example One\n" + " Example Two:\n" + " description: Example Two\n" + " Example Three:\n" + " description: Example Three\n" + " - in: query\n" + " schema:\n" + " type: string\n" + " examples:\n" + " Example Three:\n" + " description: Example Three\n" + " Example Two:\n" + " description: Example Two\n" + " Example One:\n" + " description: Example One\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}";
SerializationMatchers.assertEqualsToYamlExact(openAPI, yaml);
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project swagger-core by swagger-api.
the class ReaderTest method testTicket3731.
@Test(description = "Constraints annotations in models")
public void testTicket3731() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket3731Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /test/cart:\n" + " get:\n" + " summary: Get cart items\n" + " description: Paging follows RFC 5005.\n" + " operationId: getCart\n" + " parameters:\n" + " - name: pageSize\n" + " in: query\n" + " description: \"Number of items per page. Range[1, 200]\"\n" + " schema:\n" + " maximum: 200\n" + " minimum: 1\n" + " type: integer\n" + " format: int32\n" + " default: 50\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
reader = new Reader(new OpenAPI());
openAPI = reader.read(Ticket3731BisResource.class);
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.security.SecurityScheme.In in project swagger-core by swagger-api.
the class ReaderTest method testGetResponsesWithComposition.
@Test(description = "Responses with composition")
public void testGetResponsesWithComposition() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ResponsesResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /:\n" + " get:\n" + " summary: Simple get operation\n" + " description: Defines a simple get operation with no inputs and a complex output\n" + " object\n" + " operationId: getWithPayloadResponse\n" + " responses:\n" + " \"200\":\n" + " description: voila!\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/SampleResponseSchema'\n" + " default:\n" + " description: boo\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/GenericError'\n" + " deprecated: true\n" + " /allOf:\n" + " get:\n" + " summary: Test inheritance / polymorphism\n" + " operationId: getAllOf\n" + " parameters:\n" + " - name: number\n" + " in: query\n" + " description: Test inheritance / polymorphism\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " example: 1\n" + " responses:\n" + " \"200\":\n" + " description: bean answer\n" + " content:\n" + " application/json:\n" + " schema:\n" + " allOf:\n" + " - $ref: '#/components/schemas/MultipleSub1Bean'\n" + " - $ref: '#/components/schemas/MultipleSub2Bean'\n" + " /anyOf:\n" + " get:\n" + " summary: Test inheritance / polymorphism\n" + " operationId: getAnyOf\n" + " parameters:\n" + " - name: number\n" + " in: query\n" + " description: Test inheritance / polymorphism\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " example: 1\n" + " responses:\n" + " \"200\":\n" + " description: bean answer\n" + " content:\n" + " application/json:\n" + " schema:\n" + " anyOf:\n" + " - $ref: '#/components/schemas/MultipleSub1Bean'\n" + " - $ref: '#/components/schemas/MultipleSub2Bean'\n" + " /oneOf:\n" + " get:\n" + " summary: Test inheritance / polymorphism\n" + " operationId: getOneOf\n" + " parameters:\n" + " - name: number\n" + " in: query\n" + " description: Test inheritance / polymorphism\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " example: 1\n" + " responses:\n" + " \"200\":\n" + " description: bean answer\n" + " content:\n" + " application/json:\n" + " schema:\n" + " oneOf:\n" + " - $ref: '#/components/schemas/MultipleSub1Bean'\n" + " - $ref: '#/components/schemas/MultipleSub2Bean'\n" + "components:\n" + " schemas:\n" + " SampleResponseSchema:\n" + " type: object\n" + " GenericError:\n" + " type: object\n" + " MultipleSub1Bean:\n" + " type: object\n" + " description: MultipleSub1Bean\n" + " allOf:\n" + " - $ref: '#/components/schemas/MultipleBaseBean'\n" + " - type: object\n" + " properties:\n" + " c:\n" + " type: integer\n" + " format: int32\n" + " MultipleSub2Bean:\n" + " type: object\n" + " description: MultipleSub2Bean\n" + " allOf:\n" + " - $ref: '#/components/schemas/MultipleBaseBean'\n" + " - type: object\n" + " properties:\n" + " d:\n" + " type: integer\n" + " format: int32\n" + " MultipleBaseBean:\n" + " type: object\n" + " properties:\n" + " beanType:\n" + " type: string\n" + " a:\n" + " type: integer\n" + " format: int32\n" + " b:\n" + " type: string\n" + " description: MultipleBaseBean";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
Aggregations