@Test public void testGenerateWithDefaults() { ApiDetails apiDetails = new ApiDetails(); ResourceModel model = resource( "book-get", "Get a book by id", "book", request( "/book/{id}", HTTPMethod.GET, list( requiredParam("id", "The unique identifier for the book.", "NUMBER") ), emptyList() ), response( 200, "application/hal+json", list(), list( field("title", "Title of the book", "STRING"), field("author", "Author of the book", "STRING"), field("pages", "Number of pages in the book", "NUMBER") ), "The example response.", new Schema("MyCustomSchemaName") ) ); String rawOutput = generator.generate(apiDetails, list(model)); assertThat(rawOutput) .isEqualToNormalizingNewlines(contentOfResource("/mock-specs/default-settings-openapi3.yml")); }
@Override public String generate(ApiDetails details, List<ResourceModel> models) { List<Server> servers = new ArrayList<>(); for (String scheme : details.getSchemes()) { try { URL url = new URL(scheme, details.getHost(), details.getBasePath() == null ? "" : details.getBasePath()); servers.add(new Server().url(url.toString())); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid server URL", e); } } return generator.generateAndSerialize( models, servers, details.getName(), details.getDescription(), SpecificationGeneratorUtils.createTagDescriptionsMap(details.getTags()), details.getVersion(), SpecificationGeneratorUtils.createOauth2Configuration(details.getAuthConfig()), details.getFormat().name().toLowerCase() ); }
OpenApi30SpecificationGenerator implements SpecificationGenerator { @Override public String generate(ApiDetails details, List<ResourceModel> models) { List<Server> servers = new ArrayList<>(); for (String scheme : details.getSchemes()) { try { URL url = new URL(scheme, details.getHost(), details.getBasePath() == null ? "" : details.getBasePath()); servers.add(new Server().url(url.toString())); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid server URL", e); } } return generator.generateAndSerialize( models, servers, details.getName(), details.getDescription(), SpecificationGeneratorUtils.createTagDescriptionsMap(details.getTags()), details.getVersion(), SpecificationGeneratorUtils.createOauth2Configuration(details.getAuthConfig()), details.getFormat().name().toLowerCase() ); } }
OpenApi30SpecificationGenerator implements SpecificationGenerator { @Override public String generate(ApiDetails details, List<ResourceModel> models) { List<Server> servers = new ArrayList<>(); for (String scheme : details.getSchemes()) { try { URL url = new URL(scheme, details.getHost(), details.getBasePath() == null ? "" : details.getBasePath()); servers.add(new Server().url(url.toString())); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid server URL", e); } } return generator.generateAndSerialize( models, servers, details.getName(), details.getDescription(), SpecificationGeneratorUtils.createTagDescriptionsMap(details.getTags()), details.getVersion(), SpecificationGeneratorUtils.createOauth2Configuration(details.getAuthConfig()), details.getFormat().name().toLowerCase() ); } OpenApi30SpecificationGenerator();  OpenApi30SpecificationGenerator(OpenApi3Generator generator); }
OpenApi30SpecificationGenerator implements SpecificationGenerator { @Override public String generate(ApiDetails details, List<ResourceModel> models) { List<Server> servers = new ArrayList<>(); for (String scheme : details.getSchemes()) { try { URL url = new URL(scheme, details.getHost(), details.getBasePath() == null ? "" : details.getBasePath()); servers.add(new Server().url(url.toString())); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid server URL", e); } } return generator.generateAndSerialize( models, servers, details.getName(), details.getDescription(), SpecificationGeneratorUtils.createTagDescriptionsMap(details.getTags()), details.getVersion(), SpecificationGeneratorUtils.createOauth2Configuration(details.getAuthConfig()), details.getFormat().name().toLowerCase() ); } OpenApi30SpecificationGenerator();  OpenApi30SpecificationGenerator(OpenApi3Generator generator); @Override Specification getSpecification(); @Override String generate(ApiDetails details, List<ResourceModel> models); }
OpenApi30SpecificationGenerator implements SpecificationGenerator { @Override public String generate(ApiDetails details, List<ResourceModel> models) { List<Server> servers = new ArrayList<>(); for (String scheme : details.getSchemes()) { try { URL url = new URL(scheme, details.getHost(), details.getBasePath() == null ? "" : details.getBasePath()); servers.add(new Server().url(url.toString())); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid server URL", e); } } return generator.generateAndSerialize( models, servers, details.getName(), details.getDescription(), SpecificationGeneratorUtils.createTagDescriptionsMap(details.getTags()), details.getVersion(), SpecificationGeneratorUtils.createOauth2Configuration(details.getAuthConfig()), details.getFormat().name().toLowerCase() ); } OpenApi30SpecificationGenerator();  OpenApi30SpecificationGenerator(OpenApi3Generator generator); @Override Specification getSpecification(); @Override String generate(ApiDetails details, List<ResourceModel> models);  }