--- title: openapi3.Unmarshal description: Unmarshals the given resource into an OpenAPI 3 document. categories: [] keywords: [] params: functions_and_methods: aliases: [] returnType: openapi3.OpenAPIDocument signatures: ['openapi3.Unmarshal RESOURCE'] --- Use the `openapi3.Unmarshal` function with [global resources](g), [page resources](g), or [remote resources](g). [OpenAPI]: https://www.openapis.org/ For example, to work with a remote [OpenAPI] definition: ```go-html-template {{ $url := "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json" }} {{ $api := "" }} {{ with try (resources.GetRemote $url) }} {{ with .Err }} {{ errorf "%s" . }} {{ else with .Value }} {{ $api = . | openapi3.Unmarshal }} {{ else }} {{ errorf "Unable to get remote resource %q" $url }} {{ end }} {{ end }} ``` To inspect the data structure: ```go-html-template
{{ debug.Dump $api }}``` To list the GET and POST operations for each of the API paths: ```go-html-template {{ range $path, $details := $api.Paths }}
{{ $path }}
/pets
/pets/{petId}