@Test public void infoShouldHandleNullModels() { final OpenApiGenerator generator = new OpenApiGenerator(); final APISummary summary = generator.info("invalid", APIValidationContext.NONE); assertThat(summary).isNotNull(); assertThat(summary.getErrors()).hasSize(1) .allSatisfy(v -> assertThat(v.message()).startsWith("This document cannot be uploaded. Provide an OpenAPI document")); assertThat(summary.getWarnings()).isEmpty(); }
@Override public APISummary info(final String specification, final APIValidationContext validation) { final OpenApiModelInfo modelInfo = OpenApiModelParser.parse(specification, validation); final OasDocument model = modelInfo.getModel(); if (model == null) { return new APISummary.Builder().errors(modelInfo.getErrors()).warnings(modelInfo.getWarnings()).build(); } final OasPaths paths = model.paths; final ActionsSummary actionsSummary = determineSummaryFrom(OasModelHelper.getPathItems(paths)); final Info info = model.info; final String title = Optional.ofNullable(info).map(i -> i.title).orElse("unspecified"); final String description = Optional.ofNullable(info).map(i -> i.description).orElse("unspecified"); return new APISummary.Builder() .name(title) .description(description) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putConfiguredProperty("specification", modelInfo.getResolvedSpecification()) .build(); }
OpenApiGenerator implements APIGenerator { @Override public APISummary info(final String specification, final APIValidationContext validation) { final OpenApiModelInfo modelInfo = OpenApiModelParser.parse(specification, validation); final OasDocument model = modelInfo.getModel(); if (model == null) { return new APISummary.Builder().errors(modelInfo.getErrors()).warnings(modelInfo.getWarnings()).build(); } final OasPaths paths = model.paths; final ActionsSummary actionsSummary = determineSummaryFrom(OasModelHelper.getPathItems(paths)); final Info info = model.info; final String title = Optional.ofNullable(info).map(i -> i.title).orElse("unspecified"); final String description = Optional.ofNullable(info).map(i -> i.description).orElse("unspecified"); return new APISummary.Builder() .name(title) .description(description) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putConfiguredProperty("specification", modelInfo.getResolvedSpecification()) .build(); } }
OpenApiGenerator implements APIGenerator { @Override public APISummary info(final String specification, final APIValidationContext validation) { final OpenApiModelInfo modelInfo = OpenApiModelParser.parse(specification, validation); final OasDocument model = modelInfo.getModel(); if (model == null) { return new APISummary.Builder().errors(modelInfo.getErrors()).warnings(modelInfo.getWarnings()).build(); } final OasPaths paths = model.paths; final ActionsSummary actionsSummary = determineSummaryFrom(OasModelHelper.getPathItems(paths)); final Info info = model.info; final String title = Optional.ofNullable(info).map(i -> i.title).orElse("unspecified"); final String description = Optional.ofNullable(info).map(i -> i.description).orElse("unspecified"); return new APISummary.Builder() .name(title) .description(description) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putConfiguredProperty("specification", modelInfo.getResolvedSpecification()) .build(); }  }
OpenApiGenerator implements APIGenerator { @Override public APISummary info(final String specification, final APIValidationContext validation) { final OpenApiModelInfo modelInfo = OpenApiModelParser.parse(specification, validation); final OasDocument model = modelInfo.getModel(); if (model == null) { return new APISummary.Builder().errors(modelInfo.getErrors()).warnings(modelInfo.getWarnings()).build(); } final OasPaths paths = model.paths; final ActionsSummary actionsSummary = determineSummaryFrom(OasModelHelper.getPathItems(paths)); final Info info = model.info; final String title = Optional.ofNullable(info).map(i -> i.title).orElse("unspecified"); final String description = Optional.ofNullable(info).map(i -> i.description).orElse("unspecified"); return new APISummary.Builder() .name(title) .description(description) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putConfiguredProperty("specification", modelInfo.getResolvedSpecification()) .build(); }  @Override @SuppressWarnings({"PMD.ExcessiveMethodLength"}) APIIntegration generateIntegration(final String specification, final ProvidedApiTemplate template); @Override APISummary info(final String specification, final APIValidationContext validation); @Override Integration updateFlowExcerpts(final Integration integration); }
OpenApiGenerator implements APIGenerator { @Override public APISummary info(final String specification, final APIValidationContext validation) { final OpenApiModelInfo modelInfo = OpenApiModelParser.parse(specification, validation); final OasDocument model = modelInfo.getModel(); if (model == null) { return new APISummary.Builder().errors(modelInfo.getErrors()).warnings(modelInfo.getWarnings()).build(); } final OasPaths paths = model.paths; final ActionsSummary actionsSummary = determineSummaryFrom(OasModelHelper.getPathItems(paths)); final Info info = model.info; final String title = Optional.ofNullable(info).map(i -> i.title).orElse("unspecified"); final String description = Optional.ofNullable(info).map(i -> i.description).orElse("unspecified"); return new APISummary.Builder() .name(title) .description(description) .actionsSummary(actionsSummary) .errors(modelInfo.getErrors()) .warnings(modelInfo.getWarnings()) .putConfiguredProperty("specification", modelInfo.getResolvedSpecification()) .build(); }  @Override @SuppressWarnings({"PMD.ExcessiveMethodLength"}) APIIntegration generateIntegration(final String specification, final ProvidedApiTemplate template); @Override APISummary info(final String specification, final APIValidationContext validation); @Override Integration updateFlowExcerpts(final Integration integration);  }