$darkmode
Qore Swagger Module Reference 2.2.1
Swagger::SwaggerLoader Class Reference

Used for loading the Swagger definitions. More...

Static Public Member Functions

static string detectSourceEncoding (string str)
 tries to determine the Swagger schema source encoding automatically
 
static SwaggerSchema fromFile (string filepath, *hash< auto > opts)
 Load Swagger definition from a file. More...
 
static SwaggerSchema fromString (string swaggerSpecification, *bool json, *hash< auto > opts)
 Load Swagger definition from a string. More...
 
static SwaggerSchema fromUrl (string url, *bool json, *hash< auto > opts)
 Load Swagger definition from a URL or file path. More...
 
static hash< auto > parseSchemaContent (string filepath, string str)
 Load a schema definition from a file. More...
 
static hash< auto > parseSchemaSource (string str, string ser)
 parses the source encoding from the given string
 

Detailed Description

Used for loading the Swagger definitions.

Member Function Documentation

◆ fromFile()

static SwaggerSchema Swagger::SwaggerLoader::fromFile ( string  filepath,
*hash< auto >  opts 
)
static

Load Swagger definition from a file.

Parameters
filepathpath to the Swagger file
optsoptions as per SwaggerOptions as follows:
  • compact_serialization (default True): (type *bool) optimize the size of serialized data strings
  • def_path: (type *string) the default path to use when retrieving external schema references
  • try_import: (type *code) a call reference or closure to be passed a string name for external schema references, must take a string argument (the resource name) and return a string (the resource data)
  • parse_flags: (type *int) a binary or combination of Parse Option Flags
Exceptions
EMPTY-SCHEMA-FILESwagger file is empty
JSON-MODULE-MISSINGtrying to parse a JSON Swagger specification with the json module unavailable
YAML-MODULE-MISSINGtrying to parse a YAML Swagger specification with the yaml module unavailable
XML-MODULE-MISSINGtrying to parse an XML Swagger specification with the xml module unavailable

◆ fromString()

static SwaggerSchema Swagger::SwaggerLoader::fromString ( string  swaggerSpecification,
*bool  json,
*hash< auto >  opts 
)
static

Load Swagger definition from a string.

Parameters
swaggerSpecificationSwagger API specification
jsonwhether the specification is in JSON or YAML format; if not given the source encoding will be detected automatically
optsoptions as per SwaggerOptions as follows:
  • compact_serialization (default True): (type *bool) optimize the size of serialized data strings
  • def_path: (type *string) the default path to use when retrieving external schema references
  • try_import: (type *code) a call reference or closure to be passed a string name for external schema references, must take a string argument (the resource name) and return a string (the resource data)
  • parse_flags: (type *int) a binary or combination of Parse Option Flags
Exceptions
JSON-MODULE-MISSINGtrying to parse a JSON Swagger specification with JSON module unavailable
YAML-MODULE-MISSINGtrying to parse a YAML Swagger specification with YAML module unavailable

◆ fromUrl()

static SwaggerSchema Swagger::SwaggerLoader::fromUrl ( string  url,
*bool  json,
*hash< auto >  opts 
)
static

Load Swagger definition from a URL or file path.

Parameters
urlURL to the Swagger file; uses the FileLocationHandler to load the file
jsonwhether the specification is in JSON or YAML format; if not given the source encoding will be detected automatically
optsoptions as per SwaggerOptions as follows:
  • compact_serialization (default True): (type *bool) optimize the size of serialized data strings
  • def_path: (type *string) the default path to use when retrieving external schema references
  • try_import: (type *code) a call reference or closure to be passed a string name for external schema references, must take a string argument (the resource name) and return a string (the resource data)
  • parse_flags: (type *int) a binary or combination of Parse Option Flags
Exceptions
EMPTY-SCHEMA-FILESwagger file is empty
JSON-MODULE-MISSINGtrying to parse a JSON Swagger specification with the json module unavailable
YAML-MODULE-MISSINGtrying to parse a YAML Swagger specification with the yaml module unavailable
XML-MODULE-MISSINGtrying to parse an XML Swagger specification with the xml module unavailable

◆ parseSchemaContent()

static hash<auto> Swagger::SwaggerLoader::parseSchemaContent ( string  filepath,
string  str 
)
static

Load a schema definition from a file.

Parameters
filepathpath to the schema file
strthe file content to parse
Exceptions
EMPTY-SCHEMA-FILEschema file is empty
JSON-MODULE-MISSINGtrying to parse a JSON schema with the json module unavailable
YAML-MODULE-MISSINGtrying to parse a YAML schema specification with the yaml module unavailable
XML-MODULE-MISSINGtrying to parse an XML schema specification with the xml module unavailable