Skip to content

Commit

Permalink
ConceptApi: Fix edge case related to schemes
Browse files Browse the repository at this point in the history
If a scheme array is given on a registry, but no API URL for schemes, getSchemes will now return that array.
  • Loading branch information
stefandesu committed Mar 1, 2022
1 parent 1a7ef93 commit a1f69b5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/providers/concept-api-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export default class ConceptApiProvider extends BaseProvider {
}
}
this.has.schemes = !!this._api.schemes
// If there is no scheme API endpoint, but a list of schemes is given, use that for schemes.
if (!this.has.schemes && Array.isArray(this.schemes)) {
this.has.schemes = true
}
this.has.top = !!this._api.top
this.has.data = !!this._api.data
this.has.concepts = !!this._api.concepts || this.has.data
Expand Down Expand Up @@ -157,6 +161,10 @@ export default class ConceptApiProvider extends BaseProvider {
*/
async getSchemes(config) {
if (!this._api.schemes) {
// If an array of schemes is given, return that here
if (Array.isArray(this.schemes)) {
return this.schemes
}
throw new errors.MissingApiUrlError()
}
const schemes = await this.axios({
Expand Down

0 comments on commit a1f69b5

Please sign in to comment.