UniqueInterfaceGenerator.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.openapi;

  21. import java.io.File;
  22. import java.io.FileOutputStream;
  23. import java.util.ArrayList;
  24. import java.util.HashMap;
  25. import java.util.Iterator;
  26. import java.util.List;
  27. import java.util.Map;

  28. import org.apache.logging.log4j.Level;
  29. import org.openspcoop2.utils.LoggerWrapperFactory;
  30. import org.openspcoop2.utils.json.JSONUtils;
  31. import org.openspcoop2.utils.json.JsonPathExpressionEngine;
  32. import org.openspcoop2.utils.json.YAMLUtils;
  33. import org.openspcoop2.utils.resources.FileSystemUtilities;
  34. import org.openspcoop2.utils.rest.ApiFormats;
  35. import org.slf4j.Logger;

  36. import com.fasterxml.jackson.databind.JsonNode;

  37. import io.swagger.v3.oas.models.Components;
  38. import io.swagger.v3.oas.models.OpenAPI;
  39. import io.swagger.v3.oas.models.callbacks.Callback;
  40. import io.swagger.v3.oas.models.examples.Example;
  41. import io.swagger.v3.oas.models.headers.Header;
  42. import io.swagger.v3.oas.models.links.Link;
  43. import io.swagger.v3.oas.models.media.Schema;
  44. import io.swagger.v3.oas.models.parameters.Parameter;
  45. import io.swagger.v3.oas.models.parameters.RequestBody;
  46. import io.swagger.v3.oas.models.responses.ApiResponse;
  47. import io.swagger.v3.oas.models.security.SecurityScheme;
  48. import io.swagger.v3.parser.OpenAPIV3Parser;
  49. import io.swagger.v3.parser.converter.SwaggerConverter;
  50. import io.swagger.v3.parser.core.models.ParseOptions;
  51. import io.swagger.v3.parser.core.models.SwaggerParseResult;

  52. /**
  53.  * UniqueInterfaceGenerator
  54.  *
  55.  * @author Andrea Poli (apoli@link.it)
  56.  * @author $Author$
  57.  * @version $Rev$, $Date$
  58.  */
  59. public class UniqueInterfaceGenerator {

  60.     public static void main(String[] args) throws Exception {
  61.        
  62.         LoggerWrapperFactory.setDefaultConsoleLogConfiguration(Level.ERROR);
  63.        
  64.         if(args==null || args.length<4) {
  65.             throw new Exception("Use: UniqueInterfaceGenerator <versioneOpenAPI> <destFile> <master> <attachmentsDir>");
  66.         }
  67.        
  68.         String tipo = args[0].trim();
  69.         ApiFormats format = ApiFormats.valueOf(tipo);
  70.        
  71.         String fileDest = args[1].trim();
  72.        
  73.         UniqueInterfaceGeneratorConfig config = new UniqueInterfaceGeneratorConfig();
  74.         config.format = format;
  75.         String fileMaster = args[2].trim();
  76.         config.master =  FileSystemUtilities.readFile(fileMaster);
  77.         File fMaster = new File(fileMaster);
  78.         String ext = null;
  79.         try{
  80.             ext = fileMaster.substring(fileMaster.lastIndexOf(".")+1,fileMaster.length());
  81.         }catch(Exception e){
  82.             // ext undefined
  83.         }
  84.         config.yaml = "yaml".equalsIgnoreCase(ext);
  85.         HashMap<String,String> attachments = new HashMap<>();
  86.         File fDir = new File(args[3].trim());
  87.         if(fDir.isDirectory()==false) {
  88.             throw new Exception("attachmentsDir ["+fDir.getAbsolutePath()+"] is not directory");
  89.         }
  90.         File[] files = fDir.listFiles();
  91.         if(files!=null) {
  92.             for (int j = 0; j < files.length; j++) {
  93.                 if(files[j].getName().equals(fMaster.getName())) {
  94.                     continue;
  95.                 }
  96.                 if(files[j].isDirectory()) {
  97.                     continue;
  98.                 }
  99.                 //System.out.println("READ ["+files[j]+"] ... ");
  100.                 attachments.put(files[j].getName(), FileSystemUtilities.readFile(files[j]));
  101.                 //System.out.println("READ ["+files[j]+"] ok");
  102.             }
  103.         }
  104.         config.attachments = attachments;
  105.        
  106.         List<String> blackListParameters = null;
  107.         List<String> blackListComponents = null;
  108.         if(args.length>5) {
  109.            
  110.             String blackListParametersArgs = args[4].trim();
  111.             if(blackListParametersArgs!=null) {
  112.                 blackListParameters = new ArrayList<>();
  113.                 if(blackListParametersArgs.contains(",")) {
  114.                     String [] tmp = blackListParametersArgs.split(",");
  115.                     for (String s : tmp) {
  116.                         blackListParameters.add(s);
  117.                     }
  118.                 }else {
  119.                     blackListParameters.add(blackListParametersArgs);
  120.                 }
  121.             }
  122.            
  123.             String blackListComponentsArgs = args[5].trim();
  124.             if(blackListComponentsArgs!=null) {
  125.                 blackListComponents = new ArrayList<>();
  126.                 if(blackListComponentsArgs.contains(",")) {
  127.                     String [] tmp = blackListComponentsArgs.split(",");
  128.                     for (String s : tmp) {
  129.                         blackListComponents.add(s);
  130.                     }
  131.                 }else {
  132.                     blackListComponents.add(blackListComponentsArgs);
  133.                 }
  134.             }
  135.            
  136.         }
  137.        
  138.         generate(fileDest, config, blackListParameters, blackListComponents, true, null);
  139.     }

  140.     private static void debug(boolean debug, Logger log, String msg) {
  141.         if(debug) {
  142.             if(log!=null) {
  143.                 log.debug(msg);
  144.             }
  145.             else {
  146.                 System.out.println(msg);
  147.             }
  148.         }
  149.     }
  150.    
  151.     public static void generate(String fileDest, UniqueInterfaceGeneratorConfig config,
  152.             List<String> blackListParameters, List<String> blackListComponents,
  153.             boolean debug, Logger log) throws Exception {
  154.         String schemaRebuild = generate(config, blackListParameters, blackListComponents, debug, log);
  155.         try(FileOutputStream fout = new FileOutputStream(fileDest)){
  156.             fout.write(schemaRebuild.getBytes());
  157.             fout.flush();
  158.         }
  159.     }
  160.     public static String generate(UniqueInterfaceGeneratorConfig config,
  161.             List<String> blackListParameters, List<String> blackListComponents,
  162.             boolean debug, Logger log) throws Exception {
  163.        
  164.         SwaggerParseResult pr = null;
  165.         ParseOptions parseOptions = new ParseOptions();
  166.        
  167.         if(ApiFormats.SWAGGER_2.equals(config.format)) {
  168.             pr = new SwaggerConverter().readContents(config.master, null, parseOptions);    
  169.         }
  170.         else {
  171.             pr = new OpenAPIV3Parser().readContents(config.master, null, parseOptions);
  172.         }
  173.         StringBuilder sbParseWarningResult = new StringBuilder();
  174.         OpenAPI api = AbstractOpenapiApiReader.parseResult(LoggerWrapperFactory.getLogger(UniqueInterfaceGenerator.class), pr, sbParseWarningResult);
  175.         if(api.getComponents()==null) {
  176.             api.setComponents(new Components());
  177.         }
  178.        
  179.         Map<String,String> attachments = config.attachments;
  180.         Iterator<String> attachmentNames = attachments.keySet().iterator();
  181.         while (attachmentNames.hasNext()) {
  182.             String attachName = (String) attachmentNames.next();
  183.             String attach = attachments.get(attachName);
  184.        
  185.             debug(debug,log,"Merge ["+attachName+"] ...");
  186.             if(ApiFormats.SWAGGER_2.equals(config.format)) {
  187.                 pr = new SwaggerConverter().readContents(attach, null, parseOptions);  
  188.             }
  189.             else {
  190.                 pr = new OpenAPIV3Parser().readContents(attach, null, parseOptions);
  191.             }
  192.             OpenAPI apiInternal = AbstractOpenapiApiReader.parseResult(LoggerWrapperFactory.getLogger(UniqueInterfaceGenerator.class), pr, sbParseWarningResult);
  193.             if(apiInternal.getComponents()!=null) {
  194.                 if(apiInternal.getComponents().getCallbacks()!=null) {
  195.                     Map<String, Callback> maps = apiInternal.getComponents().getCallbacks();
  196.                     int mapsSize = 0;
  197.                     if(maps!=null && !maps.isEmpty()) {
  198.                         mapsSize = maps.size();
  199.                         Iterator<String> keys = maps.keySet().iterator();
  200.                         while (keys.hasNext()) {
  201.                             String key = (String) keys.next();
  202.                             Callback value = maps.get(key);
  203.                             api.getComponents().addCallbacks(key, value);
  204.                         }
  205.                     }
  206.                     debug(debug,log,"\t"+mapsSize+" callback");
  207.                 }
  208.                 if(apiInternal.getComponents().getExamples()!=null) {
  209.                     Map<String, Example> maps = apiInternal.getComponents().getExamples();
  210.                     int mapsSize = 0;
  211.                     if(maps!=null && !maps.isEmpty()) {
  212.                         mapsSize = maps.size();
  213.                         Iterator<String> keys = maps.keySet().iterator();
  214.                         while (keys.hasNext()) {
  215.                             String key = (String) keys.next();
  216.                             Example value = maps.get(key);
  217.                             api.getComponents().addExamples(key, value);
  218.                         }
  219.                     }
  220.                     debug(debug,log,"\t"+mapsSize+" example");
  221.                 }
  222.                 if(apiInternal.getComponents().getExtensions()!=null) {
  223.                     Map<String, Object> maps = apiInternal.getComponents().getExtensions();
  224.                     int mapsSize = 0;
  225.                     if(maps!=null && !maps.isEmpty()) {
  226.                         mapsSize = maps.size();
  227.                         Iterator<String> keys = maps.keySet().iterator();
  228.                         while (keys.hasNext()) {
  229.                             String key = (String) keys.next();
  230.                             Object value = maps.get(key);
  231.                             api.getComponents().addExtension(key, value);
  232.                         }
  233.                     }
  234.                     debug(debug,log,"\t"+mapsSize+" extensions");
  235.                 }
  236.                 if(apiInternal.getComponents().getHeaders()!=null) {
  237.                     Map<String, Header> maps = apiInternal.getComponents().getHeaders();
  238.                     int mapsSize = 0;
  239.                     if(maps!=null && !maps.isEmpty()) {
  240.                         mapsSize = maps.size();
  241.                         Iterator<String> keys = maps.keySet().iterator();
  242.                         while (keys.hasNext()) {
  243.                             String key = (String) keys.next();
  244.                             Header value = maps.get(key);
  245.                             api.getComponents().addHeaders(key, value);
  246.                         }
  247.                     }
  248.                     debug(debug,log,"\t"+mapsSize+" header");
  249.                 }
  250.                 if(apiInternal.getComponents().getLinks()!=null) {
  251.                     Map<String, Link> maps = apiInternal.getComponents().getLinks();
  252.                     int mapsSize = 0;
  253.                     if(maps!=null && !maps.isEmpty()) {
  254.                         mapsSize = maps.size();
  255.                         Iterator<String> keys = maps.keySet().iterator();
  256.                         while (keys.hasNext()) {
  257.                             String key = (String) keys.next();
  258.                             Link value = maps.get(key);
  259.                             api.getComponents().addLinks(key, value);
  260.                         }
  261.                     }
  262.                     debug(debug,log,"\t"+mapsSize+" link");
  263.                 }
  264.                 if(apiInternal.getComponents().getParameters()!=null) {
  265.                     Map<String, Parameter> maps = apiInternal.getComponents().getParameters();
  266.                     int mapsSize = 0;
  267.                     if(maps!=null && !maps.isEmpty()) {
  268.                         mapsSize = maps.size();
  269.                         Iterator<String> keys = maps.keySet().iterator();
  270.                         while (keys.hasNext()) {
  271.                             String key = (String) keys.next();
  272.                             if(blackListParameters!=null && blackListParameters.contains(key)) {
  273.                                 debug(debug,log,"Parameter '"+key+"' skipped");
  274.                                 continue;
  275.                             }
  276.                             Parameter value = maps.get(key);
  277.                             api.getComponents().addParameters(key, value);
  278.                         }
  279.                     }
  280.                     debug(debug,log,"\t"+mapsSize+" parameter");
  281.                 }
  282.                 if(apiInternal.getComponents().getRequestBodies()!=null) {
  283.                     Map<String, RequestBody> maps = apiInternal.getComponents().getRequestBodies();
  284.                     int mapsSize = 0;
  285.                     if(maps!=null && !maps.isEmpty()) {
  286.                         mapsSize = maps.size();
  287.                         Iterator<String> keys = maps.keySet().iterator();
  288.                         while (keys.hasNext()) {
  289.                             String key = (String) keys.next();
  290.                             RequestBody value = maps.get(key);
  291.                             api.getComponents().addRequestBodies(key, value);
  292.                         }
  293.                     }
  294.                     debug(debug,log,"\t"+mapsSize+" requestBody");
  295.                 }
  296.                 if(apiInternal.getComponents().getResponses()!=null) {
  297.                     Map<String, ApiResponse> maps = apiInternal.getComponents().getResponses();
  298.                     int mapsSize = 0;
  299.                     if(maps!=null && !maps.isEmpty()) {
  300.                         mapsSize = maps.size();
  301.                         Iterator<String> keys = maps.keySet().iterator();
  302.                         while (keys.hasNext()) {
  303.                             String key = (String) keys.next();
  304.                             ApiResponse value = maps.get(key);
  305.                             api.getComponents().addResponses(key, value);
  306.                         }
  307.                     }
  308.                     debug(debug,log,"\t"+mapsSize+"] response");
  309.                 }
  310.                 if(apiInternal.getComponents().getSchemas()!=null) {
  311.                     @SuppressWarnings("rawtypes")
  312.                     Map<String, Schema> maps = apiInternal.getComponents().getSchemas();
  313.                     int mapsSize = 0;
  314.                     if(maps!=null && !maps.isEmpty()) {
  315.                         mapsSize = maps.size();
  316.                         Iterator<String> keys = maps.keySet().iterator();
  317.                         while (keys.hasNext()) {
  318.                             String key = (String) keys.next();
  319.                             if(blackListComponents!=null && blackListComponents.contains(key)) {
  320.                                 debug(debug,log,"Component '"+key+"' skipped");
  321.                                 continue;
  322.                             }
  323.                             Schema<?> value = maps.get(key);
  324.                             api.getComponents().addSchemas(key, value);
  325.                         }
  326.                     }
  327.                     debug(debug,log,"\t"+mapsSize+" schema");
  328.                 }
  329.                 if(apiInternal.getComponents().getSecuritySchemes()!=null) {
  330.                     Map<String, SecurityScheme> maps = apiInternal.getComponents().getSecuritySchemes();
  331.                     int mapsSize = 0;
  332.                     if(maps!=null && !maps.isEmpty()) {
  333.                         mapsSize = maps.size();
  334.                         Iterator<String> keys = maps.keySet().iterator();
  335.                         while (keys.hasNext()) {
  336.                             String key = (String) keys.next();
  337.                             SecurityScheme value = maps.get(key);
  338.                             api.getComponents().addSecuritySchemes(key, value);
  339.                         }
  340.                     }
  341.                     debug(debug,log,"\t"+mapsSize+" security schema");
  342.                 }
  343.             }
  344.             debug(debug,log,"Merge ["+attachName+"] ok");
  345.         }
  346.        
  347.         // clean attributi non permessi in swagger editor
  348.         api.setExtensions(null);
  349.         api.getComponents().setExtensions(null);
  350.         if(api.getComponents().getHeaders()!=null) {
  351.             Map<String, Header> maps = api.getComponents().getHeaders();
  352.             if(maps!=null && !maps.isEmpty()) {
  353.                 Iterator<String> keys = maps.keySet().iterator();
  354.                 while (keys.hasNext()) {
  355.                     String key = (String) keys.next();
  356.                     Header value = maps.get(key);
  357.                     value.setExplode(null);
  358.                     value.setStyle(null);
  359.                 }
  360.             }
  361.         }
  362.         if(api.getComponents().getParameters()!=null) {
  363.             Map<String, Parameter> maps = api.getComponents().getParameters();
  364.             if(maps!=null && !maps.isEmpty()) {
  365.                 Iterator<String> keys = maps.keySet().iterator();
  366.                 while (keys.hasNext()) {
  367.                     String key = (String) keys.next();
  368.                     Parameter value = maps.get(key);
  369.                     value.setExplode(null);
  370.                     value.setStyle(null);
  371.                     //debug(debug,log,"PARAMETRO *"+key+"* ["+value.getName()+"] ["+value.getExample()+"] ["+value.getExamples()+"] ref["+value.get$ref()+"] tipo["+value.getClass().getName()+"]");
  372.                     checkSchema(0,("Parameter-"+key), value.getSchema());
  373.                 }
  374.             }
  375.         }
  376.         if(api.getComponents().getSchemas()!=null) {
  377.             @SuppressWarnings("rawtypes")
  378.             Map<String, Schema> maps = api.getComponents().getSchemas();
  379.             if(maps!=null && !maps.isEmpty()) {
  380.                 Iterator<String> keys = maps.keySet().iterator();
  381.                 while (keys.hasNext()) {
  382.                     String key = (String) keys.next();
  383.                     Schema<?> value = maps.get(key);
  384.                     String sorgente = "";
  385.                     if(value.getName()!=null) {
  386.                         sorgente = sorgente + value.getName();
  387.                     }
  388.                     else {
  389.                         sorgente = sorgente + "RootSchema";
  390.                     }
  391.                     checkSchema(0, sorgente, value);    
  392.                 }
  393.             }
  394.         }
  395.        
  396.         JsonNode jsonNode = null;
  397.         String s = null;
  398.         if(config.yaml) {
  399.             s = YAMLUtils.getObjectWriter().writeValueAsString(api);
  400.             jsonNode = YAMLUtils.getInstance().getAsNode(s);
  401.         }
  402.         else {
  403.             s = JSONUtils.getObjectWriter().writeValueAsString(api);
  404.             jsonNode = JSONUtils.getInstance().getAsNode(s);
  405.         }
  406.        
  407.         JsonPathExpressionEngine engine = new JsonPathExpressionEngine();
  408.         List<String> refPath = engine.getStringMatchPattern(jsonNode, "$..$ref");
  409.         String schemaRebuild = s;
  410.        
  411.         // Faccio due passate, prima con i caratteri " e ' in modo da risolvere le ref precisamente,
  412.         // poiche' l'algoritmo e' soggetto a problemi quando ci sono nomi inclusi in altri ref. Es.:
  413.         // test.yaml#...
  414.         // http://test/test.yaml#....
  415.         schemaRebuild = replace(refPath, schemaRebuild, true);
  416.         schemaRebuild = replace(refPath, schemaRebuild, false);
  417.            
  418.         /*
  419.         Object oDescr = engine.getMatchPattern(jsonNode, "$.info.description", JsonPathReturnType.NODE);
  420.         if(oDescr!=null) {
  421.             String descr = null;
  422.             if(oDescr instanceof List<?>) {
  423.                 @SuppressWarnings("unchecked")
  424.                 List<String> l = (List<String>) oDescr;
  425.                 if(!l.isEmpty()) {
  426.                     descr = l.get(0);
  427.                 }
  428.             }
  429.             else if(oDescr instanceof String) {
  430.                 descr = (String) oDescr;
  431.             }
  432.             else if(oDescr instanceof JsonNode) {
  433.                 JsonNode jN = (JsonNode) oDescr;
  434.                 descr = jN.asText();
  435.             }
  436.             else {
  437.                 debug(debug,log,"Description type unknown ["+oDescr.getClass().getName()+"]");
  438.             }
  439.             if(descr!=null && org.apache.commons.lang.StringUtils.isNotEmpty(descr)) {
  440.                 schemaRebuild = schemaRebuild.replace("info:", "info:\n  x-summary: \""+descr+"\"");
  441.             }
  442.         }
  443.         */
  444.        
  445.         if(schemaRebuild.startsWith("---")) {
  446.             schemaRebuild = schemaRebuild.substring("---".length());
  447.         }
  448.         if(schemaRebuild.startsWith("\n")) {
  449.             schemaRebuild = schemaRebuild.substring("\n".length());
  450.         }
  451.        
  452.         String extensions = "extensions:\n" +"    ";
  453.         schemaRebuild = schemaRebuild.replace(extensions, "");
  454.         String ext = "    x-";
  455.         String extCorrect = "  x-";
  456.         while(schemaRebuild.contains(ext)) {
  457.             schemaRebuild = schemaRebuild.replace(ext, extCorrect);
  458.         }
  459.        
  460.         return schemaRebuild;
  461.        
  462.     }

  463.     private static String replace(List<String> refPath, String schemaRebuild, boolean usePrefixChar) {
  464.         if(refPath!=null && !refPath.isEmpty()) {
  465.             for (String ref : refPath) {
  466.                
  467.                 //System.out.println("...............ANALIZZO REF ["+ref+"]");
  468.                
  469.                 if(schemaRebuild.contains(ref)) {
  470.                    
  471.                     //System.out.println(" PROCESS ["+ref+"]");
  472.                    
  473.                     if(ref.startsWith("#")==false) {
  474.                        
  475.                         //System.out.println(" PROCESS INTERNAL ["+ref+"]");
  476.                        
  477.                         String destra = ref.substring(ref.indexOf("#"));
  478.                         String refForReplace = ref;
  479.                        
  480.                         //System.out.println("destra ["+destra+"]");
  481.                         //System.out.println("destra ["+refForReplace+"]");
  482.                        
  483.                         if(usePrefixChar) {
  484.                             String rep = "\""+refForReplace+"\"";
  485.                             String destraRep = "\""+destra+"\"";
  486.                             while(schemaRebuild.contains(rep)) {
  487.                                 schemaRebuild = schemaRebuild.replace(rep, destraRep);
  488.                             }
  489.                             rep = "'"+refForReplace+"'";
  490.                             destraRep = "'"+destra+"'";
  491.                             while(schemaRebuild.contains(rep)) {
  492.                                 schemaRebuild = schemaRebuild.replace(rep, destraRep);
  493.                             }
  494.                         }
  495.                         else {
  496.                             while(schemaRebuild.contains(refForReplace)) {
  497.                                 schemaRebuild = schemaRebuild.replace(refForReplace, destra);
  498.                             }
  499.                         }
  500.                        
  501.                         if(refForReplace.startsWith("./") && refForReplace.length()>2) {
  502.                            
  503.                             //System.out.println("CASO SPECIALE!");
  504.                            
  505.                             refForReplace = refForReplace.substring(2);
  506.                            
  507.                             if(usePrefixChar) {
  508.                                 String rep = "\""+refForReplace+"\"";
  509.                                 String destraRep = "\""+destra+"\"";
  510.                                 while(schemaRebuild.contains(rep)) {
  511.                                     schemaRebuild = schemaRebuild.replace(rep, destraRep);
  512.                                 }
  513.                                 rep = "'"+refForReplace+"'";
  514.                                 destraRep = "'"+destra+"'";
  515.                                 while(schemaRebuild.contains(rep)) {
  516.                                     schemaRebuild = schemaRebuild.replace(rep, destraRep);
  517.                                 }
  518.                             }
  519.                             else {
  520.                                 while(schemaRebuild.contains(refForReplace)) {
  521.                                     schemaRebuild = schemaRebuild.replace(refForReplace, destra);
  522.                                 }
  523.                             }
  524.                         }
  525.                        
  526.                     }
  527.                 }
  528.             }
  529.         }
  530.         return schemaRebuild;
  531.     }
  532.    
  533.     private static int checkSchema(int profondita, String sorgente, Schema<?> schema) {
  534.        
  535.         if(profondita>1000) {
  536.             return profondita; // evitare stack overflow
  537.         }
  538.        
  539.         @SuppressWarnings("rawtypes")
  540.         Map<String, Schema> properties = schema.getProperties();
  541.         if(properties!=null && !properties.isEmpty()) {
  542.             for (String key : properties.keySet()) {
  543.                 Schema<?> value = properties.get(key);
  544.                 String sorgenteInterno = sorgente+".";
  545.                 if(value.getName()!=null) {
  546.                     sorgenteInterno = sorgenteInterno + value.getName();
  547.                 }
  548.                 else {
  549.                     sorgenteInterno = sorgenteInterno + "schemaProfondita"+profondita;
  550.                 }
  551.                 //debug(debug,log,"SCHEMA ("+sorgente+") *"+key+"* ["+value.getName()+"] ["+value.getType()+"] ["+value.getFormat()+"] ["+value.getExample()+"] ref["+value.get$ref()+"] schema["+value.getClass().getName()+"]");
  552.                 @SuppressWarnings("unused")
  553.                 int p = checkSchema((profondita+1),sorgenteInterno,value);
  554.             }
  555.         }
  556.        
  557.         return profondita;
  558.     }
  559.    
  560. }