@Test public void shouldReportErrorsFromInvalidPetstoreSwagger() throws IOException { final String specification = resource("/openapi/v2/invalid/invalid-scheme.petstore.json"); final ConnectorSettings connectorSettings = new ConnectorSettings.Builder() .putConfiguredProperty("specification", specification) .build(); final APISummary summary = generator.info(ApiConnectorTemplate.SWAGGER_TEMPLATE, connectorSettings); assertThat(summary.getErrors()).hasSize(1); assertThat(summary.getWarnings()).hasSize(1); }
@Override public final APISummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final OpenApiModelInfo modelInfo = parseSpecification(connectorSettings, APIValidationContext.CONSUMED_API); final OasDocument model = modelInfo.getModel(); if (model == null) { final APISummary.Builder summaryBuilder = new APISummary.Builder() .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()); if (modelInfo.getResolvedSpecification() != null) { summaryBuilder.putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()); } return summaryBuilder.build(); } final Connector connector = basicConnector(connectorTemplate, connectorSettings); final OasPaths paths = model.paths; final AtomicInteger total = new AtomicInteger(0); final Map<String, Integer> tagCounts; if (paths == null) { tagCounts = Collections.emptyMap(); } else { tagCounts = OasModelHelper.getPathItems(paths) .stream() .flatMap(p -> OasModelHelper.getOperationMap(p).values().stream()) .peek(o -> total.incrementAndGet()) .flatMap(o -> OasModelHelper.sanitizeTags(o.tags).distinct()) .collect( Collectors.groupingBy( Function.identity(), Collectors.reducing(0, (e) -> 1, Integer::sum))); } final ActionsSummary actionsSummary = new ActionsSummary.Builder() .totalActions(total.intValue()) .actionCountByTags(tagCounts) .build(); return APISummary.Builder.createFrom(connector) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putAllConfiguredProperties(connectorSettings.getConfiguredProperties()) .putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()) .build(); }
OpenApiConnectorGenerator extends ConnectorGenerator { @Override public final APISummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final OpenApiModelInfo modelInfo = parseSpecification(connectorSettings, APIValidationContext.CONSUMED_API); final OasDocument model = modelInfo.getModel(); if (model == null) { final APISummary.Builder summaryBuilder = new APISummary.Builder() .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()); if (modelInfo.getResolvedSpecification() != null) { summaryBuilder.putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()); } return summaryBuilder.build(); } final Connector connector = basicConnector(connectorTemplate, connectorSettings); final OasPaths paths = model.paths; final AtomicInteger total = new AtomicInteger(0); final Map<String, Integer> tagCounts; if (paths == null) { tagCounts = Collections.emptyMap(); } else { tagCounts = OasModelHelper.getPathItems(paths) .stream() .flatMap(p -> OasModelHelper.getOperationMap(p).values().stream()) .peek(o -> total.incrementAndGet()) .flatMap(o -> OasModelHelper.sanitizeTags(o.tags).distinct()) .collect( Collectors.groupingBy( Function.identity(), Collectors.reducing(0, (e) -> 1, Integer::sum))); } final ActionsSummary actionsSummary = new ActionsSummary.Builder() .totalActions(total.intValue()) .actionCountByTags(tagCounts) .build(); return APISummary.Builder.createFrom(connector) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putAllConfiguredProperties(connectorSettings.getConfiguredProperties()) .putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()) .build(); } }
OpenApiConnectorGenerator extends ConnectorGenerator { @Override public final APISummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final OpenApiModelInfo modelInfo = parseSpecification(connectorSettings, APIValidationContext.CONSUMED_API); final OasDocument model = modelInfo.getModel(); if (model == null) { final APISummary.Builder summaryBuilder = new APISummary.Builder() .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()); if (modelInfo.getResolvedSpecification() != null) { summaryBuilder.putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()); } return summaryBuilder.build(); } final Connector connector = basicConnector(connectorTemplate, connectorSettings); final OasPaths paths = model.paths; final AtomicInteger total = new AtomicInteger(0); final Map<String, Integer> tagCounts; if (paths == null) { tagCounts = Collections.emptyMap(); } else { tagCounts = OasModelHelper.getPathItems(paths) .stream() .flatMap(p -> OasModelHelper.getOperationMap(p).values().stream()) .peek(o -> total.incrementAndGet()) .flatMap(o -> OasModelHelper.sanitizeTags(o.tags).distinct()) .collect( Collectors.groupingBy( Function.identity(), Collectors.reducing(0, (e) -> 1, Integer::sum))); } final ActionsSummary actionsSummary = new ActionsSummary.Builder() .totalActions(total.intValue()) .actionCountByTags(tagCounts) .build(); return APISummary.Builder.createFrom(connector) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putAllConfiguredProperties(connectorSettings.getConfiguredProperties()) .putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()) .build(); } OpenApiConnectorGenerator(final Connector baseConnector, final Supplier<String> operationIdGenerator);  OpenApiConnectorGenerator(final Connector baseConnector); }
OpenApiConnectorGenerator extends ConnectorGenerator { @Override public final APISummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final OpenApiModelInfo modelInfo = parseSpecification(connectorSettings, APIValidationContext.CONSUMED_API); final OasDocument model = modelInfo.getModel(); if (model == null) { final APISummary.Builder summaryBuilder = new APISummary.Builder() .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()); if (modelInfo.getResolvedSpecification() != null) { summaryBuilder.putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()); } return summaryBuilder.build(); } final Connector connector = basicConnector(connectorTemplate, connectorSettings); final OasPaths paths = model.paths; final AtomicInteger total = new AtomicInteger(0); final Map<String, Integer> tagCounts; if (paths == null) { tagCounts = Collections.emptyMap(); } else { tagCounts = OasModelHelper.getPathItems(paths) .stream() .flatMap(p -> OasModelHelper.getOperationMap(p).values().stream()) .peek(o -> total.incrementAndGet()) .flatMap(o -> OasModelHelper.sanitizeTags(o.tags).distinct()) .collect( Collectors.groupingBy( Function.identity(), Collectors.reducing(0, (e) -> 1, Integer::sum))); } final ActionsSummary actionsSummary = new ActionsSummary.Builder() .totalActions(total.intValue()) .actionCountByTags(tagCounts) .build(); return APISummary.Builder.createFrom(connector) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putAllConfiguredProperties(connectorSettings.getConfiguredProperties()) .putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()) .build(); } OpenApiConnectorGenerator(final Connector baseConnector, final Supplier<String> operationIdGenerator);  OpenApiConnectorGenerator(final Connector baseConnector); @Override final Connector generate(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings); @Override final APISummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings); }
OpenApiConnectorGenerator extends ConnectorGenerator { @Override public final APISummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final OpenApiModelInfo modelInfo = parseSpecification(connectorSettings, APIValidationContext.CONSUMED_API); final OasDocument model = modelInfo.getModel(); if (model == null) { final APISummary.Builder summaryBuilder = new APISummary.Builder() .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()); if (modelInfo.getResolvedSpecification() != null) { summaryBuilder.putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()); } return summaryBuilder.build(); } final Connector connector = basicConnector(connectorTemplate, connectorSettings); final OasPaths paths = model.paths; final AtomicInteger total = new AtomicInteger(0); final Map<String, Integer> tagCounts; if (paths == null) { tagCounts = Collections.emptyMap(); } else { tagCounts = OasModelHelper.getPathItems(paths) .stream() .flatMap(p -> OasModelHelper.getOperationMap(p).values().stream()) .peek(o -> total.incrementAndGet()) .flatMap(o -> OasModelHelper.sanitizeTags(o.tags).distinct()) .collect( Collectors.groupingBy( Function.identity(), Collectors.reducing(0, (e) -> 1, Integer::sum))); } final ActionsSummary actionsSummary = new ActionsSummary.Builder() .totalActions(total.intValue()) .actionCountByTags(tagCounts) .build(); return APISummary.Builder.createFrom(connector) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putAllConfiguredProperties(connectorSettings.getConfiguredProperties()) .putConfiguredProperty(SPECIFICATION, modelInfo.getResolvedSpecification()) .build(); } OpenApiConnectorGenerator(final Connector baseConnector, final Supplier<String> operationIdGenerator);  OpenApiConnectorGenerator(final Connector baseConnector); @Override final Connector generate(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings); @Override final APISummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings); static final String SPECIFICATION; }