void appendServicePathsAndDefinitions() { // take copy to avoid concurrent modification exception final Collection<ObjectSpecification> allSpecs = Lists.newArrayList(specificationLoader.allSpecifications()); for (final ObjectSpecification serviceSpec : allSpecs) { final DomainServiceFacet domainServiceFacet = serviceSpec.getFacet(DomainServiceFacet.class); if (domainServiceFacet == null) { continue; } if (visibility.isPublic() && domainServiceFacet.getNatureOfService() != NatureOfService.VIEW_REST_ONLY) { continue; } if (domainServiceFacet.getNatureOfService() != NatureOfService.VIEW_MENU_ONLY && domainServiceFacet.getNatureOfService() != NatureOfService.VIEW && domainServiceFacet.getNatureOfService() != NatureOfService.VIEW_REST_ONLY) { continue; } final List<ObjectAction> serviceActions = Util.actionsOf(serviceSpec, visibility, classExcluder); if (serviceActions.isEmpty()) { continue; } appendServicePath(serviceSpec); for (final ObjectAction serviceAction : serviceActions) { appendServiceActionInvokePath(serviceSpec, serviceAction); } } }
void appendObjectPathsAndDefinitions() { // take copy to avoid concurrent modification exception final Collection<ObjectSpecification> allSpecs = Lists.newArrayList(specificationLoader.allSpecifications()); for (final ObjectSpecification objectSpec : allSpecs) { final DomainServiceFacet domainServiceFacet = objectSpec.getFacet(DomainServiceFacet.class); if (domainServiceFacet != null) { continue; } final MixinFacet mixinFacet = objectSpec.getFacet(MixinFacet.class); if (mixinFacet != null) { continue; } if (visibility.isPublic() && !Util.isVisibleForPublic(objectSpec)) { continue; } if (objectSpec.isAbstract()) { continue; } if (objectSpec.isValue()) { continue; } // special cases if (classExcluder.exclude(objectSpec)) { continue; } final List<OneToOneAssociation> objectProperties = Util.propertiesOf(objectSpec, visibility); final List<OneToManyAssociation> objectCollections = Util.collectionsOf(objectSpec, visibility); final List<ObjectAction> objectActions = Util.actionsOf(objectSpec, visibility, classExcluder); if (objectProperties.isEmpty() && objectCollections.isEmpty()) { continue; } final ModelImpl isisModel = appendObjectPathAndModelDefinitions(objectSpec); updateObjectModel(isisModel, objectSpec, objectProperties, objectCollections); for (final OneToManyAssociation objectCollection : objectCollections) { appendCollectionTo(objectSpec, objectCollection); } for (final ObjectAction objectAction : objectActions) { appendObjectActionInvokePath(objectSpec, objectAction); } } }
Swagger generate() { this.swagger = new Swagger(); swagger.basePath(basePath); swagger.info( new Info() .version( "0.0.0") // TODO: provide some way of passing the name, version etc (some sort of // SPI service?) .title(visibility.name() + " API")); appendRestfulObjectsSupportingPathsAndDefinitions(); appendLinkModelDefinition(); appendServicePathsAndDefinitions(); appendObjectPathsAndDefinitions(); appendDefinitionsForOrphanedReferences(); return swagger; }