Newer
Older
web-services / biblio-tools / v1 / inspirehep / works / expand.ini
@Nicolas Thouvenin Nicolas Thouvenin on 25 May 2022 2 KB feat: enable cache
# OpenAPI Documentation - JSON format (dot notation)
mimeType = application/json

post.operationId = post-v1-inspirehep-works-expand
post.description = Récupération des métadonnées associées à un DOI dans inspireHEP
post.summary = Récupération à partir d'un tableau d'objets avec à minima un champ value contenant le DOI
post.tags.0 = biblio-tools
post.requestBody.content.application/json.example.0.id = 1
post.requestBody.content.application/json.example.0.value = 10.1103/PhysRevLett.19.1264
post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream
post.requestBody.required = true
post.responses.default.content.application/json.example.0.id = 1
post.responses.default.content.application/json.example.0.value = { ... }
post.responses.default.content.application/json.schema.$ref =  #/components/schemas/JSONStream
post.responses.default.description = Les prefixes DOI en version textuel
post.parameters.0.description = Indenter le JSON résultant
post.parameters.0.in = query
post.parameters.0.name = indent
post.parameters.0.schema.type = boolean


# Necessary plugins
[use]
plugin = basics
plugin = analytics
plugin = storage

# Flow configuration
[JSONParse]
separator = *

[expand]
path = value
cacheName = post-v1-inspirehep-works-expand

[expand/URLFetch]
url = get('value').prepend('https://inspirehep.net/api/doi/')
json = true
target = fix('value')
timeout = 3000
retries = 2
noerror = true

; Simplification de la structure de la notice
[expand/exchange]
value = omit(['value.metadata.references'])

[expand/OBJFlatten]

[expand/replace]
path = id
value = get('id')
path = value
value = self().omit('id').mapKeys((val, key) => key.replace('value/', ''))

; Simplification de la structure du champs authorships
[expand/expand]
path = value.metadata/authors

[expand/expand/exploding]

[expand/expand/OBJFlatten]

[expand/expand/replace]
path = id
value = get('id')
path = value
value = self().omit('id').mapKeys((val, key) => key.replace('value/', ''))

[expand/expand/aggregate]

; On supprime uniqument le résulat des documents non trouvés pour
; pour les conserver sans les mettre dans le cache
[expand/swing]
test = get('value.id').isEmpty()
[expand/swing/exchange]
value = self().omit('value')

; Pour les documents sans résulat
; On donne une valeur par défaut
[swing]
test = get('value.id').isEmpty()
[swing/assign]
path = value
value = fix('n/a')

[dump]
indent = env('indent', false)