use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class FhirCodeSystemValidateCodeOperationController method validateCode.
/**
* POST-based $validate-code end-point.
* All parameters are in the request body
* @param body - FHIR parameters
* @return out - FHIR parameters
*/
@Operation(summary = "Validate a code in a code system", description = "Validate that a coded value is in a code system.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/$validate-code", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> validateCode(@Parameter(description = "The validate-code request parameters") @RequestBody Parameters.Fhir body) {
final ValidateCodeRequest request = toRequest(body, ValidateCodeRequest.class);
request.validate();
return FhirRequests.codeSystems().prepareValidateCode().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class FhirCodeSystemSubsumesOperationController method subsumes.
/*
* Subsumes POST method with code system as path parameter
*/
@Operation(summary = "Subsumption testing", description = "Test the subsumption relationship between code/Coding A and code/Coding B given the semantics of subsumption in the underlying code system (see hierarchyMeaning).")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "{codeSystemId:**}/$subsumes", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> subsumes(@Parameter(description = "The id of the code system to invoke the operation on") @PathVariable("codeSystemId") String codeSystemId, @Parameter(description = "The lookup request parameters") @RequestBody Parameters.Fhir body) {
SubsumptionRequest request = toRequest(body, SubsumptionRequest.class);
validateSubsumptionRequest(request);
// TODO: incorrect as it should use the codeSystemID instead of the systemID!
return FhirRequests.codeSystems().prepareSubsumes().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project swagger-parser by swagger-api.
the class OpenAPIDeserializerTest method testIssue343Parameter.
@Test
public void testIssue343Parameter() {
String yaml = "openapi: 3.0.0\n" + "servers: []\n" + "info:\n" + " description: bleh\n" + " version: 2.0.0\n" + " title: Test\n" + "paths:\n" + " /foo:\n" + " post:\n" + " parameters:\n" + " - in: query\n" + " name: skip\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " multipleOf: 3\n" + " responses:\n" + " '200':\n" + " description: OK\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: object\n" + " additionalProperties:\n" + " type: string\n" + " required: true\n" + "components:\n" + " schemas:\n" + " Fun:\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int32\n" + " multipleOf: 5\n" + " mySet:\n" + " type: array\n" + " uniqueItems: true\n" + " items:\n" + " type: string";
OpenAPIV3Parser parser = new OpenAPIV3Parser();
SwaggerParseResult result = parser.readContents(yaml, null, null);
OpenAPI openAPI = result.getOpenAPI();
QueryParameter qp = (QueryParameter) openAPI.getPaths().get("/foo").getPost().getParameters().get(0);
assertEquals(new BigDecimal("3"), qp.getSchema().getMultipleOf());
RequestBody bp = openAPI.getPaths().get("/foo").getPost().getRequestBody();
Schema schema = bp.getContent().get("application/json").getSchema();
assertTrue(schema.getAdditionalProperties() != null);
IntegerSchema id = (IntegerSchema) openAPI.getComponents().getSchemas().get("Fun").getProperties().get("id");
assertEquals(id.getMultipleOf(), new BigDecimal("5"));
ArraySchema ap = (ArraySchema) openAPI.getComponents().getSchemas().get("Fun").getProperties().get("mySet");
assertTrue(ap.getUniqueItems());
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project swagger-parser by swagger-api.
the class OpenAPIDeserializerTest method testExamples.
@Test
public void testExamples(@Injectable List<AuthorizationValue> auths) {
String yaml = "openapi: 3.0.1\n" + "info:\n" + " title: httpbin\n" + " version: 0.0.0\n" + "servers:\n" + " - url: http://httpbin.org\n" + "paths:\n" + " /post:\n" + " post:\n" + " summary: Returns the POSTed data\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/AnyValue'\n" + " examples:\n" + " AnObject:\n" + " $ref: '#/components/examples/AnObject'\n" + " ANull:\n" + " $ref: '#/components/examples/ANull'\n" + " application/yaml:\n" + " schema:\n" + " $ref: '#/components/schemas/AnyValue'\n" + " examples:\n" + " AString:\n" + " $ref: '#/components/examples/AString'\n" + " AnArray:\n" + " $ref: '#/components/examples/AnArray'\n" + " text/plain:\n" + " schema:\n" + " type: string\n" + " example: Hi there\n" + " application/x-www-form-urlencoded:\n" + " schema:\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " name:\n" + " type: string\n" + " example:\n" + " id: 42\n" + " name: Arthur Dent\n" + " responses:\n" + " '200':\n" + " description: OK\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: object\n" + "\n" + " #/response-headers:\n" + " /:\n" + " get:\n" + " summary: Returns a response with the specified headers\n" + " parameters:\n" + " - in: header\n" + " name: Server\n" + " required: true\n" + " schema:\n" + " type: string\n" + " examples:\n" + " httpbin:\n" + " value: httpbin\n" + " unicorn:\n" + " value: unicorn\n" + " - in: header\n" + " name: X-Request-Id\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " example: 37\n" + " responses:\n" + " '200':\n" + " description: A response with the specified headers\n" + " headers:\n" + " Server:\n" + " schema:\n" + " type: string\n" + " examples:\n" + " httpbin:\n" + " value: httpbin\n" + " unicorn:\n" + " value: unicorn\n" + " X-Request-Id:\n" + " schema:\n" + " type: integer\n" + " example: 37\n" + "\n" + "components:\n" + " schemas:\n" + " AnyValue:\n" + " nullable: true\n" + " description: Can be anything - string, object, array, null, etc.\n" + "\n" + " examples:\n" + " AString:\n" + " value: Hi there\n" + " ANumber:\n" + " value: 42\n" + " ANull:\n" + " value: null\n" + " AnArray:\n" + " value: [1, 2, 3]\n" + " AnObject:\n" + " value:\n" + " id: 42\n" + " name: Arthur Dent";
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = parser.readContents(yaml, auths, options);
OpenAPI openAPI = result.getOpenAPI();
MediaType mediaTypeJson = openAPI.getPaths().get("/post").getPost().getRequestBody().getContent().get("application/json");
Header header1 = openAPI.getPaths().get("/").getGet().getResponses().get("200").getHeaders().get("Server");
Header header2 = openAPI.getPaths().get("/").getGet().getResponses().get("200").getHeaders().get("X-Request-Id");
Parameter parameter1 = openAPI.getPaths().get("/").getGet().getParameters().get(0);
Parameter parameter2 = openAPI.getPaths().get("/").getGet().getParameters().get(1);
Assert.assertNotNull(mediaTypeJson.getExamples());
Assert.assertEquals(mediaTypeJson.getExamples().get("AnObject").get$ref(), "#/components/examples/AnObject");
Assert.assertNotNull(header1.getExamples());
Assert.assertEquals(header1.getExamples().get("httpbin").getValue(), "httpbin");
Assert.assertNotNull(header2.getExample());
Assert.assertEquals(header2.getExample(), 37);
Assert.assertNotNull(parameter1.getExamples());
Assert.assertEquals(parameter1.getExamples().get("unicorn").getValue(), "unicorn");
Assert.assertNotNull(parameter2.getExample());
Assert.assertEquals(parameter2.getExample(), 37);
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project swagger-parser by swagger-api.
the class OpenAPIDeserializerTest method propertyTest.
@Test
public void propertyTest(@Injectable List<AuthorizationValue> auths) {
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /primitiveBody/inline:\n" + " post:\n" + " x-swagger-router-controller: TestController\n" + " operationId: inlineRequiredBody\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " required: true\n" + " responses:\n" + " '200':\n" + " description: ok!";
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = parser.readContents(yaml, auths, options);
OpenAPI openAPI = result.getOpenAPI();
Map<String, Schema> properties = openAPI.getPaths().get("/primitiveBody/inline").getPost().getRequestBody().getContent().get("application/json").getSchema().getProperties();
assertTrue(properties.get("name") instanceof StringSchema);
}
Aggregations