public Path set(String method, Operation op) { if ("get".equals(method)) { return get(op); } if ("put".equals(method)) { return put(op); } if ("head".equals(method)) { return head(op); } if ("post".equals(method)) { return post(op); } if ("delete".equals(method)) { return delete(op); } if ("patch".equals(method)) { return patch(op); } if ("options".equals(method)) { return options(op); } return null; }
protected Map<String, Path> generateEntityRUDPaths(ModelImpl entityModel) { return Collections.singletonMap( String.format(ENTITY_RUD_OPS, entityModel.getName()), new Path() .get(generateEntityReadOperation(entityModel)) .put(generateEntityUpdateOperation(entityModel)) .delete(generateEntityDeleteOperation(entityModel))); }
break; case PUT: path.put(buildOperation(endpoint, tag, methodType)); break; case DELETE:
break; case PUT: path.put(buildOperation(endpoint, tag, methodType)); break; case DELETE:
this.swagger.getPath(path).put(createOperation(method, operationTags));
break; case HttpConstants.ANNOTATION_METHOD_PUT: path.put(operation); break; case HttpConstants.ANNOTATION_METHOD_POST:
@Test public void shouldMakeNonUniqueOperationIdsUnique() { final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo")) .post(new Operation().operationId("foo")).put(new Operation().operationId("bar"))); final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(), createSettingsFrom(swagger)); final List<ConnectorAction> actions = generated.getActions(); assertThat(actions).hasSize(3); assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo")); assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1")); assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar")); }
@Test public void shouldMakeNonUniqueOperationIdsUnique() { final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo")) .post(new Operation().operationId("foo")).put(new Operation().operationId("bar"))); final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(), createSettingsFrom(swagger)); final List<ConnectorAction> actions = generated.getActions(); assertThat(actions).hasSize(3); assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo")); assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1")); assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar")); }
break; case PUT: path.put(op); break; case PATCH:
private Path path2UtilAvailable(Parameter idParam) { Path path = new Path(); if (idParam != null) { path.setParameters(Collections.singletonList(paramId())); } io.swagger.models.Operation get = new io.swagger.models.Operation(); get.addTag(this.currentTag.getName()); get.setResponses(responseMap( Operation.STATUS_CODE_OK, responseOk(), Operation.STATUS_CODE_UNAVAILABLE, responseNoContent(), Operation.STATUS_CODE_NOT_FOUND, responseGenericError() )); path.setGet(get); io.swagger.models.Operation patchOrPut = new io.swagger.models.Operation(); patchOrPut.addTag(this.currentTag.getName()); patchOrPut.setParameters(Collections.singletonList(paramBody(ServiceStat.class))); patchOrPut.setResponses(responseMap( Operation.STATUS_CODE_OK, responseOk(template(ServiceStats.class)), Operation.STATUS_CODE_NOT_FOUND, responseGenericError() )); path.put(patchOrPut); path.patch(patchOrPut); return path; }
@Test public void shouldValidateOperationUniqueness() { final Swagger swagger = new Swagger() .path("/path", new Path().get(new Operation().operationId("o1")).post(new Operation().operationId("o2"))) .path("/other", new Path().patch(new Operation().operationId("o2")).put(new Operation().operationId("o3"))) .path("/more", new Path().options(new Operation().operationId("o4")).delete(new Operation().operationId("o3"))); final SwaggerModelInfo info = new SwaggerModelInfo.Builder().model(swagger).build(); final SwaggerModelInfo validated = SyndesisSwaggerValidationRules.validateUniqueOperationIds(info); final List<Violation> warnings = validated.getWarnings(); assertThat(warnings).hasSize(1); final Violation nonUniqueWarning = warnings.get(0); assertThat(nonUniqueWarning.error()).isEqualTo("non-unique-operation-ids"); assertThat(nonUniqueWarning.property()).isNull(); assertThat(nonUniqueWarning.message()).isEqualTo("Found operations with non unique operationIds: o2, o3"); } }
@Test public void shouldValidateOperationUniqueness() { final Swagger swagger = new Swagger() .path("/path", new Path().get(new Operation().operationId("o1")).post(new Operation().operationId("o2"))) .path("/other", new Path().patch(new Operation().operationId("o2")).put(new Operation().operationId("o3"))) .path("/more", new Path().options(new Operation().operationId("o4")).delete(new Operation().operationId("o3"))); final SwaggerModelInfo info = new SwaggerModelInfo.Builder().model(swagger).build(); final SwaggerModelInfo validated = SyndesisSwaggerValidationRules.validateUniqueOperationIds(info); final List<Violation> warnings = validated.getWarnings(); assertThat(warnings).hasSize(1); final Violation nonUniqueWarning = warnings.get(0); assertThat(nonUniqueWarning.error()).isEqualTo("non-unique-operation-ids"); assertThat(nonUniqueWarning.property()).isNull(); assertThat(nonUniqueWarning.message()).isEqualTo("Found operations with non unique operationIds: o2, o3"); } }
Operation.STATUS_CODE_NOT_FOUND, responseGenericError() )); path.put(put);