Transforms JSON-Schema to be usable as Swagger endpoint query param schema
@param {Object} processedSchema
@returns {*}
481922
function transformIntoQueryParamSchema(processedSchema) {
  return _.transform(
    processedSchema.items.properties,
    (result, value, key) => {
      const parameter = Object.assign(
        {
          name: key
        },
        value,
        {
          type: Array.isArray(value.type) ? value.type[0] : value.type,
          required: !_.includes(value.type, "null")
        }
      );
      result.push(parameter);
    },
    []
  );
}
1369086
function resolveSchemaDeps(result, schema, schemasMap) {
  if (! (schema.deps || []).length) return result.concat([ schema ]);

  return schema.deps.reduce(function (result, tableName) {
    return (result.indexOf(schemasMap[tableName]) >= 0) ?
           result :
           result.concat(resolveSchemaDeps(result, schemasMap[tableName], schemasMap));
  }, result).concat([ schema ]);
}
541101
async function onUIGetSettingsSchema(schemaJson, curSettings) {
    const readJSON = (basename) => {
        return JSON.parse(pi.pluginfs.readFileSync(basename).toString());
    };
    const schemaDefaultJson = readJSON('settings_schema_default.json');
    const schemaWlanJson = readJSON('settings_schema_wlan.json');
    if (!curSettings) curSettings
        = {webapi:{api_filter:{}},mqtt:{},network:{}};

    let setProp = {};// schema_json.properties;
    // API Filters settings are not implemented yet
    let filters = localStorage.getItem('API_FILTERS'
        ,{clientA:{filter:''},clientB:{filter:''},clientC:{filter:''}}); // Sample clients
    for( let clname in filters ){
        setProp[clname] = {
            title: clname+' client allowed path in regexp',
            type: 'string',
        };
        let filter = filters[clname].filter;

        if (filter != null) {
            setProp[clname].default = filter;
        }

        curSettings.webapi.api_filter[clname] = filter;
    }
    schemaJson.properties.webapi.properties.api_filter.properties = setProp;


    return listNetInterfaces().then(([interfaces, bWlanExist]) => {
        let curInterf;
        let curAp;
        if (typeof curSettings.network.interfaces == 'object') {
            for (let k of Object.keys(curSettings.network.interfaces)) {
                curInterf = k;
                if (k.indexOf('wlan')==0) {
                    curAp = curSettings.network.interfaces[k].apname;
                }
            }
        }

        // Previously set interface does not exist any more..
        if (curInterf != undefined && interfaces.indexOf(curInterf)<0) {
            log(`Previously set interface ${curInterf} does not exist now`);
            interfaces.unshift(curInterf);
        }

        interfaces.forEach((interf)=>{
            let prop = {};

            prop[interf] = (interf.indexOf('wlan')==0 ?
                schemaWlanJson : schemaDefaultJson);

            schemaJson.properties.network.properties.interfaces.oneOf.push({
                title: interf,
                type: 'object',
                additionalProperties: false,
                properties: prop,
            });
        });

        if (schemaJson.properties.network.properties.interfaces.oneOf.length==0) {
            throw new Error({error: 'No network available.'});
        }

        if (!bWlanExist) {
            return schemaJson;
        }

        return scanWiFi().then((aps) => {
            const enumap = schemaWlanJson.properties.apname.enum;
            for (const ap of aps) {
                enumap.push(ap);
            }
            if (enumap.length == 0) {
                log('No valid Wifi IP found.');
            }
            if (curAp !=undefined && enumap.indexOf(curAp)<0) {
                log(`Previously set AP ${curAp} is invisible now`);
                enumap.unshift(curAp);
            }
            return schemaJson;
        });
    }).catch((err) => {
        //console.error('err:'+JSON.stringify(err));
        delete schemaJson.properties.network.properties.interfaces;
        delete schemaJson.properties.network.properties.detail;
        delete schemaJson.properties.network.properties.root_passwd;
        /* eslint-disable max-len */
        schemaJson.properties.network.properties.network_settings = {
            type: 'object',
            description:
`nmcli should be installed to setup network configuration. Execute

"$ sudo apt-get install network-manager"

or

"$ sudo yum install NetworkManager"

Also, you need to free your network devices from existing framework by, for example, edit /etc/network/interfaces to contain only two lines:

"auto lo",
"iface lo inet loopback"

and reboot. In addition, you may want to uninstall dhcpcd5 (if exist) by

"$ sudo apt-get purge dhcpcd5"`,
        };
        /* eslint-enable max-len */
        return schemaJson;
    });
}
1102412
private static Map<String, Type> flatten(Schema schema) throws SchemaConversionException {
    Map<String, Type> flattened = new LinkedHashMap<>();
    Schema recordSchema = determineType(schema);

    Preconditions.checkArgument(Type.RECORD.equals(recordSchema.getType()), "%s is expected. Schema: %s",
        Type.RECORD, recordSchema);

    for (Field f : recordSchema.getFields()) {
      produceFlattenedHelper(f, flattened);
    }
    return flattened;
  }
944259
function processXsd() {
	console.log();
	console.log('Processing XML schema...');
	var src = x2j.xml2json(xsdStr,{"attributePrefix": "@","valueProperty": false, "coerceTypes": false});
	var obj = xsd.getJsonSchema(src,'nitro-schema','',true);

	console.log('Validating generated JSON schema...');
	var validate = ajv.compile(jsonSchema);
	validate(obj);
	var errors = validate.errors;
	if (errors) {
		console.log(errors);
		return false;
	}
	else {
		fs.writeFileSync('./nitroApi/nitro-schema.yaml',yaml.safeDump(obj),'utf8');

		var existing = openapi.components.schemas;
		var root = obj.properties;
		openapi.components.schemas = obj.definitions;
		openapi.components.schemas.nitro = root.nitro;
		openapi.components.schemas.nitro.additionalProperties = true; // cope with undefined 'items'
		openapi.components.schemas.ErrorModel = existing.ErrorModel;
		recurse(openapi.components.schemas,{},function(obj,key,state){
			if ((key === '$ref') && (typeof obj.$ref === 'string') && (obj.$ref.startsWith('#/definitions/'))) {
				obj.$ref = obj.$ref.replace('#/definitions/','#/components/schemas/');
			}
		});

		return true;
	}
}
1042115
function identifySchema(obj) {
  if (obj) {
    const code = obj.code;
    const action = obj.action;
    const category = Dialect[action];

    if (category) {
      if (action === 'msg' || action == 'invalid-request') {
        // First handle the schemas which are a category unto themselves.
        return category;
      } else if (code) {
        // Then handle codes. Fall through if there is a code,
        // but it doesn't exist for the identified category.
        const categoryCode = category[code];

        if (categoryCode) {
          return categoryCode;
        }
      } else {
        // If there is no code, attempted to fetch the request sub-object.
        return category.request;
      }
    }
    
    if (code) {
      // If there is a code, but it wasn't associated with the identified
      // category (if any), then attempt to locate it in the general responses.
      let category = Dialect.general;

      if (category) {
        return category[code];
      }
    }
  }
}
921918
def query_schema(self, name, param):
        

        alias, name, need_list = self.parse_entry(name)

        if not name:
            result = self.process_multiple_query(need_list, param)
        else:
            result = self.process_single_query(name, need_list, param)
        return alias, result
1051632
function (Schema, key) {
		if (!this.KEY_SCHEMA_REG_EXP.test(key)) {
			throw new Error('invalid schema key format. must be match with ' + this.KEY_SCHEMA_REG_EXP.source);
		}

		var schema = new Schema();

		key.replace(this.KEY_SCHEMA_REG_EXP, this._patchFormat(schema));

		return schema;
	}
122308
function getSchema(connection) {
  const schemaSql = getDrillSchemaSql(
    connection.drillCatalog
    // connection.drillSchema
  );
  return runQuery(schemaSql, connection).then(queryResult =>
    formatSchemaQueryResults(queryResult)
  );
}
412449
def _parse_request(self, schema, req, locations):
        """"""
        if schema.many:
            assert (
                "json" in locations
            ), "schema.many=True is only supported for JSON location"
            # The ad hoc Nested field is more like a workaround or a helper,
            # and it servers its purpose fine. However, if somebody has a desire
            # to re-design the support of bulk-type arguments, go ahead.
            parsed = self.parse_arg(
                name="json",
                field=ma.fields.Nested(schema, many=True),
                req=req,
                locations=locations,
            )
            if parsed is missing:
                parsed = []
        else:
            argdict = schema.fields
            parsed = {}
            for argname, field_obj in iteritems(argdict):
                if MARSHMALLOW_VERSION_INFO[0] < 3:
                    parsed_value = self.parse_arg(argname, field_obj, req, locations)
                    # If load_from is specified on the field, try to parse from that key
                    if parsed_value is missing and field_obj.load_from:
                        parsed_value = self.parse_arg(
                            field_obj.load_from, field_obj, req, locations
                        )
                        argname = field_obj.load_from
                else:
                    argname = field_obj.data_key or argname
                    parsed_value = self.parse_arg(argname, field_obj, req, locations)
                if parsed_value is not missing:
                    parsed[argname] = parsed_value
        return parsed
372459
function getSchema(connection) {
  const schemaSql = getSchemaSql(connection.database);
  return runQuery(schemaSql, connection).then(queryResult =>
    formatSchemaQueryResults(queryResult)
  );
}
562432
function generateSchemaRaw(modelParam, opts = {}) {
  validate.notNil(modelParam, "modelParam is mandatory");

  let models;
  if (_.isArray(modelParam)) {
    models = modelParam;
  } else if (_.isObject(modelParam)) {
    models = [modelParam];
  } else {
    throw new Error("modelParam should be an object or an array of objects");
  }

  return models.map(model => {
    const processedSchema = modelTransformer.transformJsonSchemaFromModel(
      model,
      opts
    );

    return {
      name: model.name,
      schema: processedSchema
    };
  });
}
139157
function instrumentSchemaForExpressGraphQL(schema) {
  addTracingToResolvers(schema);
  addSchemaLevelResolveFunction(schema, (root, args, ctx, info) => {
    const operation = print(info.operation);
    const fragments = Object.keys(info.fragments).map(k => print(info.fragments[k])).join('\n');

    ctx.tracer.log('request.query', `${operation}\n${fragments}`);
    ctx.tracer.log('request.variables', info.variableValues);
    ctx.tracer.log('request.operationName', info.operation.name);
    return root;
  });
}
807078
function resolveSchemasDeps(schemas, schemasMap, callback) {
  async.reduce(schemas, [], function (result, schema, next) {
    tryAndDelay(resolveSchemaDeps, result, schema, schemasMap, next);
  }, function (err, result) {
    return err ? callback(err) : callback(null, _.uniq(result));
  });
}
504833
def query_schema(query_params_schema, min_version=None,
                 max_version=None):
    """"""

    def add_validator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            if 'req' in kwargs:
                req = kwargs['req']
            else:
                req = args[1]

            if req.environ['wsgiorg.routing_args'][1]:
                if _schema_validation_helper(query_params_schema,
                                        req.environ['wsgiorg.routing_args'][1],
                                        args, kwargs, is_body=False):
                    _remove_unexpected_query_parameters(query_params_schema,
                                                         req)
            else:
                if _schema_validation_helper(query_params_schema,
                                            req.GET.dict_of_lists(),
                                            args, kwargs, is_body=False):
                    _remove_unexpected_query_parameters(query_params_schema,
                                                         req)
            return func(*args, **kwargs)
        return wrapper

    return add_validator
28245
function simpleType_jsonSchema(name) {
  var result = {};
  result.type = this.instance.toLowerCase();

  __processOptions(result, this.options)

  return result;
}
164310
function getSchema(connection) {
  return runQuery(SCHEMA_SQL_V1, connection)
    .then(queryResult => formatSchemaQueryResults(queryResult))
    .catch(() =>
      runQuery(SCHEMA_SQL_V0, connection).then(queryResult =>
        formatSchemaQueryResults(queryResult)
      )
    );
}