use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testTicket3624.
@Test(description = "Optional handling")
public void testTicket3624() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Service.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /example/model:\n" + " get:\n" + " tags:\n" + " - ExampleService\n" + " summary: ' Retrieve models for display to the user'\n" + " operationId: getModels\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/Response'\n" + " /example/model/by/ids:\n" + " get:\n" + " tags:\n" + " - ExampleService\n" + " summary: ' Retrieve models by their ids'\n" + " operationId: getModelsById\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/ByIdResponse'\n" + " /example/containerized/model:\n" + " get:\n" + " tags:\n" + " - ExampleService\n" + " summary: ' Retrieve review insights for a specific product'\n" + " operationId: getContainerizedModels\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/ContainerizedResponse'\n" + "components:\n" + " schemas:\n" + " Model:\n" + " type: object\n" + " properties:\n" + " text:\n" + " type: string\n" + " title:\n" + " type: string\n" + " active:\n" + " type: boolean\n" + " schemaParent:\n" + " $ref: '#/components/schemas/Model'\n" + " optionalString:\n" + " type: string\n" + " parent:\n" + " $ref: '#/components/schemas/Model'\n" + " id:\n" + " type: integer\n" + " format: int32\n" + " Response:\n" + " type: object\n" + " properties:\n" + " count:\n" + " type: integer\n" + " format: int32\n" + " models:\n" + " type: array\n" + " items:\n" + " $ref: '#/components/schemas/Model'\n" + " ByIdResponse:\n" + " type: object\n" + " properties:\n" + " modelsById:\n" + " type: object\n" + " additionalProperties:\n" + " $ref: '#/components/schemas/Model'\n" + " ContainerizedResponse:\n" + " type: object\n" + " properties:\n" + " totalCount:\n" + " type: integer\n" + " format: int32\n" + " containerizedModels:\n" + " type: array\n" + " items:\n" + " $ref: '#/components/schemas/ModelContainer'\n" + " ModelContainer:\n" + " type: object\n" + " properties:\n" + " text:\n" + " type: string\n" + " model:\n" + " $ref: '#/components/schemas/Model'\n" + " id:\n" + " type: integer\n" + " format: int32";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testRequestBodyWithFilter.
@Test(description = "RequestBody with filter")
public void testRequestBodyWithFilter() {
Components components = new Components();
components.addRequestBodies("User", new RequestBody());
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(SimpleRequestBodyResource.class);
OpenAPISpecFilter filterImpl = new RefRequestBodyFilter();
SpecFilter f = new SpecFilter();
openAPI = f.filter(openAPI, filterImpl, null, null, null);
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" + " requestBody:\n" + " $ref: '#/components/requestBodies/User'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " deprecated: true\n" + "components:\n" + " schemas:\n" + " User:\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " username:\n" + " type: string\n" + " firstName:\n" + " type: string\n" + " lastName:\n" + " type: string\n" + " email:\n" + " type: string\n" + " password:\n" + " type: string\n" + " phone:\n" + " type: string\n" + " userStatus:\n" + " type: integer\n" + " description: User Status\n" + " format: int32\n" + " xml:\n" + " name: User\n" + " requestBodies:\n" + " User: {}\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testCallbackWithRef.
@Test(description = "Callback with Ref")
public void testCallbackWithRef() {
Components components = new Components();
components.addCallbacks("Callback", new Callback().addPathItem("/post", new PathItem().description("Post Path Item")));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefCallbackResource.class);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /simplecallback:\n" + " get:\n" + " summary: Simple get operation\n" + " operationId: getWithNoParameters\n" + " responses:\n" + " \"200\":\n" + " description: voila!\n" + " callbacks:\n" + " testCallback1:\n" + " $ref: '#/components/callbacks/Callback'\n" + "components:\n" + " callbacks:\n" + " Callback:\n" + " /post:\n" + " description: Post Path Item\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testTicket3092.
@Test
public void testTicket3092() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(UploadResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /upload:\n" + " post:\n" + " operationId: uploadWithBean\n" + " requestBody:\n" + " content:\n" + " multipart/form-data:\n" + " schema:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " picture:\n" + " $ref: '#/components/schemas/picture'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json: {}\n" + " /upload/requestbody:\n" + " post:\n" + " operationId: uploadWithBeanAndRequestBody\n" + " requestBody:\n" + " content:\n" + " multipart/form-data:\n" + " schema:\n" + " $ref: '#/components/schemas/UploadRequest'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json: {}\n" + "components:\n" + " schemas:\n" + " picture:\n" + " type: object\n" + " format: binary\n" + " UploadRequest:\n" + " title: Schema for Upload\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " picture:\n" + " type: string\n" + " format: binary";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testHeaderWithRef.
@Test(description = "Header with Ref")
public void testHeaderWithRef() {
Components components = new Components();
components.addHeaders("Header", new Header().description("Header Description"));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefHeaderResource.class);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /path:\n" + " get:\n" + " summary: Simple get operation\n" + " description: Defines a simple get operation with no inputs and a complex output\n" + " operationId: getWithPayloadResponse\n" + " responses:\n" + " \"200\":\n" + " description: voila!\n" + " headers:\n" + " Rate-Limit-Limit:\n" + " description: The number of allowed requests in the current period\n" + " $ref: '#/components/headers/Header'\n" + " style: simple\n" + " schema:\n" + " type: integer\n" + " deprecated: true\n" + "components:\n" + " headers:\n" + " Header:\n" + " description: Header Description\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
Aggregations