openapi: yaml support for file:// protocol #806

This commit is contained in:
Sören Weber 2024-03-17 00:47:48 +01:00
parent b18bca9172
commit aa97395407
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
4 changed files with 2689 additions and 99 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
{{- $page := .page }}
{{- with $page }}
<script src="{{"js/js-yaml.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}" defer></script>
{{- $urlOpenapi := "" }}
{{- $relOpenapi := "" }}
{{- $cssInProject := false }}

View file

@ -473,7 +473,15 @@ function initOpenapi( update, attrs ){
validatorUrl: 'none',
};
if( oc.dataset.openapiSpec ){
Object.assign( options, { spec: JSON.parse( oc.dataset.openapiSpec ) });
try{
Object.assign( options, { spec: JSON.parse( oc.dataset.openapiSpec ) });
} catch( err ){
try{
Object.assign( options, { spec: jsyaml.load( oc.dataset.openapiSpec ) });
} catch( err ){
console.log( err );
}
}
}
else{
Object.assign( options, { url: oc.dataset.openapiUrl });