swagger_parser library
Parses OpenAPI sources and generates Dart libraries.
Use FileSchemaSourceLoader to read a local file on Dart I/O platforms.
Use SchemaSource for text or bytes on the VM and web.
Classes
- ApiDefinition
- HTTP operations and schemas extracted from one API description.
- ApiDefinitionExtractor
- Extracts route operations and schemas from a validated document.
- ApiDiscriminator
- Resolved tag mappings for a schema union.
- ApiEncoding
- Multipart encoding for one property or sequential item.
- ApiMediaType
- Schemas for one payload representation.
- ApiOperation
- One HTTP method mounted at a path template.
- ApiParameter
- A parameter on an extracted operation.
- ApiRequestBody
- The effective request payload.
- ApiResponse
- A response for one status selector.
- ApiSchema
- A schema in the registry. Links retain recursive schema identity.
- DartArgumentDefault
- A schema default and its constant Dart expression.
- DartClientBody
- A request body.
- DartClientOperation
- One outbound HTTP method.
- DartClientParameter
- A typed HTTP argument and its wire name.
- DartCodeBuilder
- Builds a Dart syntax tree from a library model.
- DartDocumentation
- Source documentation for a generated declaration.
- DartDtoModel
- A Dart class and its constructor fields.
- DartEnumModel
- A Dart enum and its JSON scalar values.
- DartFacadeModel
- The public entry point for generated clients.
- DartFieldModel
- A DTO field and its JSON rules.
- DartGenerationModel
- Dart libraries to generate and diagnostics from mapping.
- DartGenerator
- Generates formatted Dart libraries from a DartGenerationModel.
- DartLibraryModel
- One Dart library and its declarations.
- DartMappedDefault
- An allocated constant expression for one mapped JSON default.
- DartMatchBranch
- A branch of a structural union.
- DartModelMapper
- Maps API schemas and outbound operations to Dart declarations.
- DartOpenEnumNames
- Names and payload type for an enum with unknown values.
- DartOutputPlanner
- Checks output paths and sorts files before rendering.
- DartScalarCodec
- Resolved imports, wire type, and predicates for a mapped schema.
- DartSchemaMatcher
- Constraints for one generated JSON predicate.
- DartSourceRenderer
- Emits and formats Dart source in memory.
- DartStatusVariant
- One HTTP status in a sealed result.
- DartStructuralUnion
- A union selected by the shape of its JSON input.
- DartTupleModel
- A JSON tuple with typed positions and an optional tail.
- DartTypeReference
- A Dart type with an optional import and type arguments.
- DartUnionModel
- A sealed type with object DTO variants.
- DartValueModel
- A named JSON value with a Dart type.
- DefaultDartCodeBuilder
- Builds Dart DTOs and HTTP clients.
- Diagnostic
- A diagnostic message with a code and optional source position.
- DocumentLoader
- Loads external sources by retrieval URI.
- DocumentNode
- One object at a physical JSON Pointer in an OpenAPI document.
- EffectivePathItem
- Effective fields of a Path Item after following its references.
- FileSchemaSourceLoader
- Loads a local file as UTF-8 schema text on Dart I/O platforms.
- GeneratedFile
- A file the caller can write to disk or add to an archive.
- GenerationConfig
- Generation options for generated Dart source.
- GenerationPlan
- The ordered files to render.
- GenerationResult
- Generated files and diagnostics from one run.
- JsonValue
- An explicitly present JSON value. JsonValue(null) differs from an absent optional JsonValue field. Containers are copied and recursively immutable.
- LocatedNode
- An OpenAPI node with its physical document and schema context.
- NameReplacementRule
- Replaces all regex matches in names of one category.
- NamingConfig
- Naming options. Source identifiers and wire values remain unchanged.
- NormalizeConfig
- Controls changes to a parsed OpenAPI document.
- OpenApiDocument
- A parsed document that preserves its declared specification version.
- OpenApiNormalizer
- Normalizes a parsed document in its declared OpenAPI version.
- OpenApiParser
- Parses Swagger 2.0, OpenAPI 3.0, 3.1, and 3.2 documents.
- OpenApiReferenceResolver
- Builds a reference graph without changing the document.
- OpenApiV30AdditionalProperties
- A boolean or schema for extra object properties.
- OpenApiV30AdditionalPropertiesAllowed
- A boolean rule for extra object properties.
- OpenApiV30AdditionalPropertiesSchema
- A schema that constrains extra object properties.
- OpenApiV30ApiKeySecurityScheme
- An API key passed in a named request field.
- OpenApiV30Callback
- Callback path items indexed by runtime expression.
- OpenApiV30Components
- Named definitions for use elsewhere in the document.
- OpenApiV30Contact
- Contact details for questions about the API.
- OpenApiV30Discriminator
- A property that selects a schema for a payload.
- OpenApiV30Document
- Root of the OpenAPI 3.0 document tree.
- OpenApiV30Encoding
- Serialization rules for one request body property.
- OpenApiV30Example
- An inline example or a link to an external example.
- OpenApiV30ExternalDocumentation
- A link to additional documentation.
- OpenApiV30Header
- The value and serialization rules for an HTTP header.
- OpenApiV30HttpSecurityScheme
- An HTTP authentication scheme for the Authorization header.
- OpenApiV30Info
- Title, version, and publication details of the described API.
-
OpenApiV30Inline<
T extends OpenApiV30JsonSerializable> - A definition stored at its point of use.
- OpenApiV30JsonSerializable
- A document object that can export its fields as JSON.
- OpenApiV30License
- License terms for the API.
- OpenApiV30Link
- Inputs for another operation derived from this response.
- OpenApiV30MediaType
- Schema, examples, and encoding for one media type.
- OpenApiV30OAuth2SecurityScheme
- OAuth 2.0 authorization settings.
- OpenApiV30OAuthFlow
- Authorization endpoints and scopes for an OAuth flow.
- OpenApiV30OAuthFlows
- OAuth grant types supported by the authorization server.
- OpenApiV30OpenIdConnectSecurityScheme
- OpenID Connect discovery settings.
- OpenApiV30Operation
- The request and possible responses for one HTTP method.
- OpenApiV30Parameter
- A named input to an operation.
- OpenApiV30PathItem
- Operations and shared parameters for one path.
- OpenApiV30Paths
- Path items indexed by relative API path.
-
OpenApiV30Reference<
T extends OpenApiV30JsonSerializable> - A reference to a local or external definition.
-
OpenApiV30RefOr<
T extends OpenApiV30JsonSerializable> - An inline definition or a reference to another definition.
- OpenApiV30RequestBody
- Request payloads indexed by media type.
- OpenApiV30Response
- A documented response and its payload metadata.
- OpenApiV30Responses
-
Responses indexed by status code or
default. - OpenApiV30Schema
- The structure, constraints, and annotations of a payload.
- OpenApiV30SecurityRequirement
- Security schemes that must be satisfied together.
- OpenApiV30SecurityScheme
- Credentials an operation can require.
- OpenApiV30Server
- A base URL with optional template variables.
- OpenApiV30ServerVariable
- A substitution for a variable in a server URL.
- OpenApiV30Tag
- Metadata for a group of operations.
- OpenApiV30Xml
- XML element, attribute, and namespace rules for a property.
- OpenApiV31ApiKeySecurityScheme
- An API key passed in a named request field.
- OpenApiV31BooleanSchema
- A schema that accepts every instance or none.
- OpenApiV31Callback
- Callback path items indexed by runtime expression.
- OpenApiV31Components
- Named definitions for use elsewhere in the document.
- OpenApiV31Contact
- Contact details for questions about the API.
- OpenApiV31Discriminator
- A property that selects a schema for a payload.
- OpenApiV31Document
- Root of the OpenAPI 3.1 document tree.
- OpenApiV31Encoding
- Serialization rules for one request body property.
- OpenApiV31Example
- An inline example or a link to an external example.
- OpenApiV31ExternalDocumentation
- A link to additional documentation.
- OpenApiV31ForeignSchema
- Preserves keywords of a dialect the parser cannot interpret.
- OpenApiV31Header
- The value and serialization rules for an HTTP header.
- OpenApiV31HttpSecurityScheme
- An HTTP authentication scheme for the Authorization header.
- OpenApiV31Info
- Title, version, and publication details of the described API.
-
OpenApiV31Inline<
T extends OpenApiV31JsonSerializable> - A definition stored at its point of use.
- OpenApiV31JsonSerializable
- A document object that can export its fields as JSON.
- OpenApiV31License
- License terms for the API.
- OpenApiV31Link
- Inputs for another operation derived from this response.
- OpenApiV31MediaType
- Schema, examples, and encoding for one media type.
- OpenApiV31MutualTlsSecurityScheme
- Client authentication with a TLS certificate.
- OpenApiV31OAuth2SecurityScheme
- OAuth 2.0 authorization settings.
- OpenApiV31OAuthFlow
- Authorization endpoints and scopes for an OAuth flow.
- OpenApiV31OAuthFlows
- OAuth grant types supported by the authorization server.
- OpenApiV31ObjectSchema
- JSON Schema keywords and annotations for a 3.1 schema object.
- OpenApiV31OpenIdConnectSecurityScheme
- OpenID Connect discovery settings.
- OpenApiV31Operation
- The request and possible responses for one HTTP method.
- OpenApiV31Parameter
- A named input to an operation.
- OpenApiV31PathItem
- Operations and shared parameters for one path.
- OpenApiV31Paths
- Path items indexed by relative API path.
-
OpenApiV31Reference<
T extends OpenApiV31JsonSerializable> - A reference to a local or external definition.
-
OpenApiV31RefOr<
T extends OpenApiV31JsonSerializable> - An inline definition or a reference to another definition.
- OpenApiV31RequestBody
- Request payloads indexed by media type.
- OpenApiV31Response
- A documented response and its payload metadata.
- OpenApiV31Responses
-
Responses indexed by status code or
default. - OpenApiV31Schema
- A boolean or object schema with its effective dialect.
- OpenApiV31SchemaType
-
The single name or list used for the schema's
type. - OpenApiV31SecurityRequirement
- Security schemes that must be satisfied together.
- OpenApiV31SecurityScheme
- Credentials an operation can require.
- OpenApiV31Server
- A base URL with optional template variables.
- OpenApiV31ServerVariable
- A substitution for a variable in a server URL.
- OpenApiV31SingleType
- A schema type written as one name.
- OpenApiV31Tag
- Metadata for a group of operations.
- OpenApiV31TypeSet
- Schema types written as an array of names.
- OpenApiV31Xml
- XML element, attribute, and namespace rules for a property.
- OpenApiV32ApiKeySecurityScheme
- An API key passed in a named request field.
- OpenApiV32BooleanSchema
- A schema that accepts every instance or none.
- OpenApiV32Callback
- Callback path items indexed by runtime expression.
- OpenApiV32Components
- Named definitions for use elsewhere in the document.
- OpenApiV32Contact
- Contact details for questions about the API.
- OpenApiV32Discriminator
- A property that selects a schema for a payload.
- OpenApiV32Document
- Root of the OpenAPI 3.2 document tree.
- OpenApiV32Encoding
- Serialization rules for one request body property.
- OpenApiV32Example
- An inline example or a link to an external example.
- OpenApiV32ExternalDocumentation
- A link to additional documentation.
- OpenApiV32ForeignSchema
- Preserves keywords of a dialect the parser cannot interpret.
- OpenApiV32Header
- The value and serialization rules for an HTTP header.
- OpenApiV32HttpSecurityScheme
- An HTTP authentication scheme for the Authorization header.
- OpenApiV32Info
- Title, version, and publication details of the described API.
-
OpenApiV32Inline<
T extends OpenApiV32JsonSerializable> - A definition stored at its point of use.
- OpenApiV32JsonSerializable
- A document object that can export its fields as JSON.
- OpenApiV32License
- License terms for the API.
- OpenApiV32Link
- Inputs for another operation derived from this response.
- OpenApiV32MediaType
- Schema, examples, and encoding for one media type.
- OpenApiV32MutualTlsSecurityScheme
- Client authentication with a TLS certificate.
- OpenApiV32OAuth2SecurityScheme
- OAuth 2.0 authorization settings.
- OpenApiV32OAuthFlow
- Authorization endpoints and scopes for an OAuth flow.
- OpenApiV32OAuthFlows
- OAuth grant types supported by the authorization server.
- OpenApiV32ObjectSchema
- JSON Schema keywords and annotations for a 3.2 schema object.
- OpenApiV32OpenIdConnectSecurityScheme
- OpenID Connect discovery settings.
- OpenApiV32Operation
- The request and possible responses for one HTTP method.
- OpenApiV32Parameter
- A named input to an operation.
- OpenApiV32PathItem
- Operations and shared parameters for one path.
- OpenApiV32Paths
- Path items indexed by relative API path.
-
OpenApiV32Reference<
T extends OpenApiV32JsonSerializable> - A reference to a local or external definition.
-
OpenApiV32RefOr<
T extends OpenApiV32JsonSerializable> - An inline definition or a reference to another definition.
- OpenApiV32RequestBody
- Request payloads indexed by media type.
- OpenApiV32Response
- A documented response and its payload metadata.
- OpenApiV32Responses
-
Responses indexed by status code or
default. - OpenApiV32Schema
- A boolean or object schema with its effective dialect.
- OpenApiV32SchemaType
-
The single name or list used for the schema's
type. - OpenApiV32SecurityRequirement
- Security schemes that must be satisfied together.
- OpenApiV32SecurityScheme
- Credentials an operation can require.
- OpenApiV32Server
- A base URL with optional template variables.
- OpenApiV32ServerVariable
- A substitution for a variable in a server URL.
- OpenApiV32SingleType
- A schema type written as one name.
- OpenApiV32Tag
- Metadata for a group of operations.
- OpenApiV32TypeSet
- Schema types written as an array of names.
- OpenApiV32Xml
- XML element, attribute, and namespace rules for a property.
- OpenApiValidator
- Checks a document and reports validation diagnostics.
- OpenApiVersion
- Feature family and the exact version declared in the source document.
- OperationFilterConfig
- Selects outbound operations. Named schemas remain available.
- ParameterExclusion
- Excludes an effective HTTP parameter by its wire identity.
- ParameterSerialization
- Effective wire settings for a request parameter.
- ParseConfig
- Controls source positions, unknown fields, and nesting depth.
- PipelineConfig
- In-memory settings shared by CLI and browser generation.
- PlannedDartFile
- A Dart library scheduled for output.
- ReferenceGraph
- References indexed by the physical location of each URI field.
- ReferenceTarget
- An object or boolean schema at a resolved location.
- ResolvedOperationValidator
- Checks operations reachable from paths, webhooks, and callbacks.
- ResolvedReference
- One reference from a source field to its initial target.
- SchemaSource
- In-memory JSON or YAML input for the parser.
- SourceLocation
- One-based line/column and zero-based UTF-16 offset in the source text.
- SwaggerParserRunner
- Runs the configured OpenAPI processing stages and generates Dart files.
- SwaggerV2AdditionalProperties
- A boolean or schema for extra object properties.
- SwaggerV2AdditionalPropertiesAllowed
- A boolean rule for extra object properties.
- SwaggerV2AdditionalPropertiesSchema
- A schema that constrains extra object properties.
- SwaggerV2ApiKeySecurityScheme
- An API key passed in a named request field.
- SwaggerV2BasicSecurityScheme
- HTTP Basic authentication.
- SwaggerV2BodyParameter
- An operation parameter that describes the request body.
- SwaggerV2Contact
- Contact details for questions about the API.
- SwaggerV2Document
- Root of the Swagger 2.0 document tree.
- SwaggerV2ExternalDocumentation
- A link to additional documentation.
- SwaggerV2Header
- The value and serialization rules for an HTTP header.
- SwaggerV2Info
- Title, version, and publication details of the described API.
-
SwaggerV2Inline<
T extends SwaggerV2JsonSerializable> - A definition stored at its point of use.
- SwaggerV2Items
- The element type and constraints of an array parameter or header.
- SwaggerV2JsonSerializable
- A document object that can export its fields as JSON.
- SwaggerV2License
- License terms for the API.
- SwaggerV2OAuth2SecurityScheme
- OAuth 2.0 authorization settings.
- SwaggerV2Operation
- The request and possible responses for one HTTP method.
- SwaggerV2Parameter
- A named input to an operation.
- SwaggerV2PathItem
- Operations and shared parameters for one path.
- SwaggerV2Paths
- Path items indexed by relative API path.
-
SwaggerV2Reference<
T extends SwaggerV2JsonSerializable> - A reference to a local or external definition.
-
SwaggerV2RefOr<
T extends SwaggerV2JsonSerializable> - An inline definition or a reference to another definition.
- SwaggerV2Response
- A documented response and its payload metadata.
- SwaggerV2Responses
-
Responses indexed by status code or
default. - SwaggerV2Schema
- The structure, constraints, and annotations of a payload.
- SwaggerV2SchemaItems
- One schema for all items or one schema per tuple position.
- SwaggerV2SchemaType
-
The single name or list used for the schema's
type. - SwaggerV2SecurityRequirement
- Security schemes that must be satisfied together.
- SwaggerV2SecurityScheme
- Credentials an operation can require.
- SwaggerV2SingleItems
- A schema that applies to every item in an array.
- SwaggerV2SingleType
- A schema type written as one name.
- SwaggerV2Tag
- Metadata for a group of operations.
- SwaggerV2TupleItems
- Schemas that apply to successive array positions.
- SwaggerV2TypeSet
- Schema types written as an array of names.
- SwaggerV2ValueParameter
- A primitive, array, or file parameter outside the request body.
- SwaggerV2Xml
- XML element, attribute, and namespace rules for a property.
- TypeMapping
- Replaces a scalar or object schema with an imported Dart type.
- TypeMappingCodec
- Public synchronous functions that convert non-null JSON values.
- TypeMappingDefault
- An imported constant for one JSON schema default.
- ValidationReport
- The diagnostics from one validation pass.
Enums
- ApiMetadataMode
- Selects public operation metadata and request attachment.
- DartClientParameterLocation
- Wire location of an HTTP argument.
- DartHttpMedia
- Payload codecs for generated clients.
- DartParameterObjectShape
- Property types of an object parameter.
- DartPathStyle
- Expansion style for a path parameter.
- DartQueryListFormat
- Wire format for a scalar query array.
- DelimitedQueryArrayExplodeMode
- Handles query arrays with a delimited style and explode set to true. OpenAPI does not define this combination.
- DiagnosticSeverity
- The effect of a diagnostic on processing.
- DtoSerializer
- Selects the generated DTO codec.
- HttpClientBackend
- Selects the generated HTTP client implementation.
- NamingTarget
- Selects the generated names changed by a replacement rule.
- NodeKind
- Object roles that contain references or operations.
- OpenApiFamily
- The specification family that defines a document's structure.
- OpenApiV30ApiKeyLocation
- The part of the request that carries an API key.
- OpenApiV30SecuritySchemeType
- The authentication mechanism of a security scheme.
- OpenApiV30Type
- A type name accepted by OpenAPI 3.0.
- OpenApiV31ApiKeyLocation
- The part of the request that carries an API key.
- OpenApiV31SecuritySchemeType
- The authentication mechanism of a security scheme.
- OpenApiV31Type
- A type name accepted by OpenAPI 3.1.
- OpenApiV32ApiKeyLocation
- The part of the request that carries an API key.
- OpenApiV32ParameterLocation
- The part of the request that carries a parameter.
- OpenApiV32SecuritySchemeType
- The authentication mechanism of a security scheme.
- OpenApiV32Style
- How a parameter is serialized in a request.
- OpenApiV32Type
- A type name accepted by OpenAPI 3.2.
- OpenApiV32XmlNodeType
- XML representation of a schema value.
- ResponseMode
- Selects the HTTP response API.
- SchemaDialect
- Schema keyword sets supported by parsing and reference resolution.
- SchemaFormat
- The decoding mode for source text.
- SwaggerV2ApiKeyLocation
- The part of the request that carries an API key.
- SwaggerV2CollectionFormat
- The wire format of an array parameter.
- SwaggerV2OAuthFlow
- The OAuth grant declared by a Swagger 2.0 security scheme.
- SwaggerV2ParameterLocation
- The part of the request that carries a parameter.
- SwaggerV2Type
- A type name accepted by Swagger 2.0.
- TypeMappingDirection
- Selects the request or response use of a schema.
- UnknownFieldPolicy
- How the parser handles unknown fields on fixed-field objects.
- UnknownValueMode
- Handles unknown enum values, discriminator tags, or unmatched unions.
Mixins
- OpenApiV30Object
- Common fields for specification extensions and unrecognized properties.
- OpenApiV31Object
- Common fields for specification extensions and unrecognized properties.
- OpenApiV32Object
- Common fields for specification extensions and unrecognized properties.
- SwaggerV2Object
- Preserves extensions and unknown fields without interpreting them.
Extensions
- DartOperationNaming on ApiOperation
- Names used when mapping HTTP operations to Dart.
- SwaggerV2TypeName on SwaggerV2Type
- The spelling of a Swagger type in the source document.
Functions
-
validateOutputPath(
String path) → void - Rejects paths that cannot safely represent an output within an archive.
-
withParseWarnings<
T> (void onWarning(Diagnostic)?, T read()) → T -
Runs
readwith a handler for recoverable input errors. A nullonWarningselects strict parsing. Concurrent calls are independent.
Typedefs
- DartFormField = ({String? contentType, DartArgumentDefault? defaultValue, DartDocumentation documentation, bool file, String key, String name, bool required, String? separator, DartTypeReference type})
- One form field.
- DartQueryObjectShape = DartParameterObjectShape
- Property types of a deepObject query parameter.
- OpenApiV30ParameterLocation = OpenApiParameterLocation
- The part of the request that carries a parameter.
- OpenApiV30Style = OpenApiParameterStyle
- The serialization style of a parameter.
- OpenApiV31ParameterLocation = OpenApiParameterLocation
- The part of the request that carries a parameter.
- OpenApiV31Style = OpenApiParameterStyle
- The serialization style of a parameter.
- ReferenceLocation = ({Uri? documentUri, String pointer})
- Physical document URI and JSON Pointer. In-memory input can omit the URI.
Exceptions / Errors
- GenerationException
- A generation failure and its diagnostics.
- OpenApiException
- An input failure with optional source coordinates.
- ReferenceResolutionException
- A reference, resource identifier, or external document could not be resolved.
- SchemaParseException
- A syntax or structural error in the input document.
- UnsupportedOpenApiVersionException
- The declared specification version has no parser.