Skip to main content

open_api_schema_generator

Function open_api_schema_generator 

Source
pub fn open_api_schema_generator<S: BuildHasher>(
    server_root: &str,
    api_version: &str,
    schema_base_url: &str,
    sds: &[StructureDefinition],
    search_parameters: &[SearchParameter],
    supported_resource_names: &HashSet<String, S>,
) -> Result<OpenAPI, OperationOutcomeError>
Expand description

Generates an OpenAPI document containing only the FHIR resources supported by the server.

Resource and complex-type schemas are represented as external $refs pointing to {schema_base_url}/{TypeName}. This keeps the generated document small while allowing individual schemas to be served on demand from a separate endpoint.

For each supported resource, the generated document includes endpoints for reading, creating, searching, updating, and deleting resources, as applicable.

§Arguments

  • server_root - The root URL of the FHIR server.
  • api_version - The version of the API represented by the generated document.
  • schema_base_url - The base URL from which individual FHIR schemas are served (e.g. /schemas/fhir).
  • sds - All available [StructureDefinition]s, including resource and complex-type definitions.
  • search_parameters - All available [SearchParameter]s used to generate resource search operations.
  • supported_resource_names - The set of FHIR resource type names supported by the server. Resource definitions not present in this set are excluded from the generated document.

§Errors

Returns an OperationOutcomeError if a supported resource [StructureDefinition] does not contain a type name.

§Returns

An OpenAPI document containing the server configuration, schemas, and paths for all supported resources and applicable complex types.