/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
/** * Generates the JsonSchema of a Representation. * * @param representation * The representation. * @param schemas * @param m * @throws JsonProcessingException */ public static void fillSchemas(Representation representation, Map<String, String> schemas, ObjectMapper m) throws JsonProcessingException { fillSchemas(representation.getName(), representation.getDescription(), representation.isRaw(), representation.getExtendedType(), representation.getProperties(), schemas, m); }
Map<String, Map<String, Object>> representationSamples = getSamples(contract); raml.setSecuritySchemes(getSecuritySchemes(endpoint)); fillResources(raml.getResources(), m, contract, representationSamples); raml.getSchemas().add(schemas); for (Representation representation : contract.getRepresentations()) { if (RamlUtils.isPrimitiveType(representation.getName())) { continue; RamlUtils.fillSchemas(representation, schemas, m); } catch (JsonProcessingException e) { LOGGER.log(Level.WARNING,
Action action, Operation operation, MimeType ramlInRepresentation) { ramlInRepresentation.setType(operation.getInputPayLoad().getType()); if (RamlUtils.isPrimitiveType(operation.getInputPayLoad().getType())) { Property inRepresentationPrimitive = new Property(); inRepresentationPrimitive.setName(""); .getType()); SimpleTypeSchema inRepresentationSchema = RamlUtils .generatePrimitiveSchema(inRepresentationPrimitive); try { ramlInRepresentation.setSchema(m try { ramlInRepresentationWithMediaType .setExample(getExampleFromPayLoad( operation.getInputPayLoad(), representationSamples, mediaType));
Map<String, Map<String, Object>> representationSamples = getSamples(contract); raml.setSecuritySchemes(getSecuritySchemes(endpoint)); fillResources(raml.getResources(), m, contract, representationSamples); raml.getSchemas().add(schemas); for (Representation representation : contract.getRepresentations()) { if (RamlUtils.isPrimitiveType(representation.getName())) { continue; RamlUtils.fillSchemas(representation, schemas, m); } catch (JsonProcessingException e) { LOGGER.log(Level.WARNING,
Action action, Operation operation, MimeType ramlInRepresentation) { ramlInRepresentation.setType(operation.getInputPayLoad().getType()); if (RamlUtils.isPrimitiveType(operation.getInputPayLoad().getType())) { Property inRepresentationPrimitive = new Property(); inRepresentationPrimitive.setName(""); .getType()); SimpleTypeSchema inRepresentationSchema = RamlUtils .generatePrimitiveSchema(inRepresentationPrimitive); try { ramlInRepresentation.setSchema(m try { ramlInRepresentationWithMediaType .setExample(getExampleFromPayLoad( operation.getInputPayLoad(), representationSamples, mediaType));
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
/** * Generates the JsonSchema of a Representation. * * @param representation * The representation. * @param schemas * @param m * @throws JsonProcessingException */ public static void fillSchemas(Representation representation, Map<String, String> schemas, ObjectMapper m) throws JsonProcessingException { fillSchemas(representation.getName(), representation.getDescription(), representation.isRaw(), representation.getExtendedType(), representation.getProperties(), schemas, m); }
/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }
Map<String, Map<String, Object>> representationSamples = getSamples(contract); raml.setSecuritySchemes(getSecuritySchemes(endpoint)); fillResources(raml.getResources(), m, contract, representationSamples); raml.getSchemas().add(schemas); for (Representation representation : contract.getRepresentations()) { if (RamlUtils.isPrimitiveType(representation.getName())) { continue; RamlUtils.fillSchemas(representation, schemas, m); } catch (JsonProcessingException e) { LOGGER.log(Level.WARNING,
Action action, Operation operation, MimeType ramlInRepresentation) { ramlInRepresentation.setType(operation.getInputPayLoad().getType()); if (RamlUtils.isPrimitiveType(operation.getInputPayLoad().getType())) { Property inRepresentationPrimitive = new Property(); inRepresentationPrimitive.setName(""); .getType()); SimpleTypeSchema inRepresentationSchema = RamlUtils .generatePrimitiveSchema(inRepresentationPrimitive); try { ramlInRepresentation.setSchema(m try { ramlInRepresentationWithMediaType .setExample(getExampleFromPayLoad( operation.getInputPayLoad(), representationSamples, mediaType));
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
/** * Generates the JsonSchema of a Representation. * * @param representation * The representation. * @param schemas * @param m * @throws JsonProcessingException */ public static void fillSchemas(Representation representation, Map<String, String> schemas, ObjectMapper m) throws JsonProcessingException { fillSchemas(representation.getName(), representation.getDescription(), representation.isRaw(), representation.getExtendedType(), representation.getProperties(), schemas, m); }
/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }
Map<String, Map<String, Object>> representationSamples = getSamples(contract); raml.setSecuritySchemes(getSecuritySchemes(endpoint)); fillResources(raml.getResources(), m, contract, representationSamples); raml.getSchemas().add(schemas); for (Representation representation : contract.getRepresentations()) { if (RamlUtils.isPrimitiveType(representation.getName())) { continue; RamlUtils.fillSchemas(representation, schemas, m); } catch (JsonProcessingException e) { LOGGER.log(Level.WARNING,
Action action, Operation operation, MimeType ramlInRepresentation) { ramlInRepresentation.setType(operation.getInputPayLoad().getType()); if (RamlUtils.isPrimitiveType(operation.getInputPayLoad().getType())) { Property inRepresentationPrimitive = new Property(); inRepresentationPrimitive.setName(""); .getType()); SimpleTypeSchema inRepresentationSchema = RamlUtils .generatePrimitiveSchema(inRepresentationPrimitive); try { ramlInRepresentation.setSchema(m try { ramlInRepresentationWithMediaType .setExample(getExampleFromPayLoad( operation.getInputPayLoad(), representationSamples, mediaType));
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
/** * Generates the JsonSchema of a Representation. * * @param representation * The representation. * @param schemas * @param m * @throws JsonProcessingException */ public static void fillSchemas(Representation representation, Map<String, String> schemas, ObjectMapper m) throws JsonProcessingException { fillSchemas(representation.getName(), representation.getDescription(), representation.isRaw(), representation.getExtendedType(), representation.getProperties(), schemas, m); }
/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }