/** * Retrieves the Swagger API declaration corresponding to a category of the * given Restlet Web API {@link Definition} * * @param definition * The Restlet Web API {@link Definition} * @param sectionName * The category of the API declaration * @return The Swagger {@link ApiDeclaration} of the given category */ public static ApiDeclaration getApiDeclaration(Definition definition, String sectionName) { ApiDeclaration result = new ApiDeclaration(); Contract contract = definition.getContract(); // fill API declaration main attributes fillApiDeclarationMainAttributes(definition, result); // fill API declaration resources Collection<String> usedModels = fillApiDeclarationResources(contract, result, sectionName); // fill API declaration representations fillApiDeclarationRepresentations(contract, result, usedModels); return result; }
Definition definition = new Definition(); definition.setContract(new Contract()); Endpoint endpoint = new Endpoint(apiDeclaration.getBasePath()); definition.getEndpoints().add(endpoint); fillEndpointAuthorization(apiDeclaration.getAuthorizations(), endpoint);
apiDeclaration.setApiVersion(definition.getVersion()); if (!definition.getEndpoints().isEmpty()) { endpoint = definition.getEndpoints().get(0); apiDeclaration.setBasePath(endpoint.computeUrl()); } else { endpoint = new Endpoint("http://example.com"); (endpoint.getAuthenticationProtocol()))) { authorizations.setBasicAuth(new BasicAuthorizationDeclaration()); apiDeclaration.setAuthorizations(authorizations); } else if (ChallengeScheme.HTTP_OAUTH.getName().equals( (endpoint.getAuthenticationProtocol())) apiDeclaration.setSwaggerVersion(SWAGGER_VERSION); apiDeclaration.setResourcePath("");
List<String> declaredPathVariables, List<String> declaredTypes) { List<String> apiProduces = apiDeclaration.getProduces(); List<String> apiConsumes = apiDeclaration.getConsumes(); Map<String, List<String>> subtypes = new LinkedHashMap<>(); Representation representation;
.getModels().entrySet()) { ModelDeclaration model = modelEntry.getValue(); if (model.getSubTypes() != null && !model.getSubTypes().isEmpty()) {
String key = apis.get(0).getPath(); ApiDeclaration firstApiDeclaration = apiDeclarations.get(key); basePath = firstApiDeclaration.getBasePath();
apiDeclaration.setApiVersion(definition.getVersion()); if (!definition.getEndpoints().isEmpty()) { endpoint = definition.getEndpoints().get(0); apiDeclaration.setBasePath(endpoint.computeUrl()); } else { endpoint = new Endpoint("http://example.com"); (endpoint.getAuthenticationProtocol()))) { authorizations.setBasicAuth(new BasicAuthorizationDeclaration()); apiDeclaration.setAuthorizations(authorizations); } else if (ChallengeScheme.HTTP_OAUTH.getName().equals( (endpoint.getAuthenticationProtocol())) apiDeclaration.setSwaggerVersion(SWAGGER_VERSION); apiDeclaration.setResourcePath("");
List<String> declaredPathVariables, List<String> declaredTypes) { List<String> apiProduces = apiDeclaration.getProduces(); List<String> apiConsumes = apiDeclaration.getConsumes(); Map<String, List<String>> subtypes = new LinkedHashMap<>(); Representation representation;
.getModels().entrySet()) { ModelDeclaration model = modelEntry.getValue(); if (model.getSubTypes() != null && !model.getSubTypes().isEmpty()) {
String key = apis.get(0).getPath(); ApiDeclaration firstApiDeclaration = apiDeclarations.get(key); basePath = firstApiDeclaration.getBasePath();
apiDeclaration.setApiVersion(definition.getVersion()); if (!definition.getEndpoints().isEmpty()) { endpoint = definition.getEndpoints().get(0); apiDeclaration.setBasePath(endpoint.computeUrl()); } else { endpoint = new Endpoint("http://example.com"); (endpoint.getAuthenticationProtocol()))) { authorizations.setBasicAuth(new BasicAuthorizationDeclaration()); apiDeclaration.setAuthorizations(authorizations); } else if (ChallengeScheme.HTTP_OAUTH.getName().equals( (endpoint.getAuthenticationProtocol())) apiDeclaration.setSwaggerVersion(SWAGGER_VERSION); apiDeclaration.setResourcePath("");
Definition definition = new Definition(); definition.setContract(new Contract()); Endpoint endpoint = new Endpoint(apiDeclaration.getBasePath()); definition.getEndpoints().add(endpoint); fillEndpointAuthorization(apiDeclaration.getAuthorizations(), endpoint);
List<String> declaredPathVariables, List<String> declaredTypes) { List<String> apiProduces = apiDeclaration.getProduces(); List<String> apiConsumes = apiDeclaration.getConsumes(); Map<String, List<String>> subtypes = new LinkedHashMap<>(); Representation representation;
.getModels().entrySet()) { ModelDeclaration model = modelEntry.getValue(); if (model.getSubTypes() != null && !model.getSubTypes().isEmpty()) {
/** * Retrieves the Swagger API declaration corresponding to a category of the * given Restlet Web API {@link Definition} * * @param definition * The Restlet Web API {@link Definition} * @param sectionName * The category of the API declaration * @return The Swagger {@link ApiDeclaration} of the given category */ public static ApiDeclaration getApiDeclaration(Definition definition, String sectionName) { ApiDeclaration result = new ApiDeclaration(); Contract contract = definition.getContract(); // fill API declaration main attributes fillApiDeclarationMainAttributes(definition, result); // fill API declaration resources Collection<String> usedModels = fillApiDeclarationResources(contract, result, sectionName); // fill API declaration representations fillApiDeclarationRepresentations(contract, result, usedModels); return result; }
String key = apis.get(0).getPath(); ApiDeclaration firstApiDeclaration = apiDeclarations.get(key); basePath = firstApiDeclaration.getBasePath();
apiDeclaration.setApiVersion(definition.getVersion()); if (!definition.getEndpoints().isEmpty()) { endpoint = definition.getEndpoints().get(0); apiDeclaration.setBasePath(endpoint.computeUrl()); } else { endpoint = new Endpoint("http://example.com"); (endpoint.getAuthenticationProtocol()))) { authorizations.setBasicAuth(new BasicAuthorizationDeclaration()); apiDeclaration.setAuthorizations(authorizations); } else if (ChallengeScheme.HTTP_OAUTH.getName().equals( (endpoint.getAuthenticationProtocol())) apiDeclaration.setSwaggerVersion(SWAGGER_VERSION); apiDeclaration.setResourcePath("");
Definition definition = new Definition(); definition.setContract(new Contract()); Endpoint endpoint = new Endpoint(apiDeclaration.getBasePath()); definition.getEndpoints().add(endpoint); fillEndpointAuthorization(apiDeclaration.getAuthorizations(), endpoint);