mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
openapi: yaml support for file:// protocol #806
This commit is contained in:
parent
b18bca9172
commit
aa97395407
4 changed files with 2689 additions and 99 deletions
File diff suppressed because it is too large
Load diff
1548
exampleSite/content/shortcodes/openapi/petstore.yaml
Normal file
1548
exampleSite/content/shortcodes/openapi/petstore.yaml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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 }}
|
||||
|
|
|
@ -473,7 +473,15 @@ function initOpenapi( update, attrs ){
|
|||
validatorUrl: 'none',
|
||||
};
|
||||
if( 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 });
|
||||
|
|
Loading…
Reference in a new issue