headers and body are not included
transfluxus opened this issue · 1 comments
transfluxus commented
Q&A (please complete the following information)
- OS: Ubuntu
- Environment: [e.g. firefox, node 18]
- Method of installation:npm
- Swagger-Client version: 3.18.5
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
async execute(parameters: { [paramName: string]: string | number }, requestBody: any): Promise<object> {
const {operationId} = this.openApiOperation
let response
const request: {
spec: object,
operationId: string,
headers?: { [headerName: string]: string },
parameters: { [paramName: string]: string | number },
body?: any
} = {
spec: this.bridge.openapiSchema,
operationId,
parameters
}
if (requestBody) {
request.body = JSON.parse(requestBody)
request.headers = {'Content-Type': 'application/json'}
}
try {
response = await SwaggerClient.execute(request)
console.log(response)
} catch (e) {
return Promise.reject(e)
}
The request object looks like this:
{
"spec": {
"openapi": "3.0.0",
"info": {
"title": "Deployed Resources",
"version": "1.0.0"
},
"servers": [
{
"url": "https://demo.dataverse.org"
}
],
"paths": {
"/api/dataverses/{identifier}/datasets": {
"post": {
"operationId": "createDatasetFromJsonLd",
"headers": {
"Content-Type": "application/json"
},
"parameters": [
{
"name": "identifier",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
},
"responses": {
"default": {
"description": "Default Response.",
"content": {
"*/*": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"get": {
"operationId": "getPrivateUrl",
"parameters": [
{
"name": "persistentId",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"default": {
"description": "Default Response.",
"content": {
"*/*": {
"schema": {
"type": "object"
}
}
}
}
}
}
}
},
"security": [
{
"ApiKeyAuth": []
}
]
}
}
},
"components": {
"schemas": {},
"securitySchemas": {
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "X-Dataverse-key"
}
}
}
},
"operationId": "createDatasetFromJsonLd",
"parameters": {
"identifier": "bcn-tetst"
},
"body": {
"datasetVersion": {
"license": {
"name": "CC0 1.0",
"uri": "http://creativecommons.org/publicdomain/zero/1.0"
},
"metadataBlocks": {
"citation": {
"displayName": "Citation Metadata",
"fields": [
{
"typeName": "title",
"multiple": false,
"typeClass": "primitive",
"value": "Replication Data for: Title"
},
{
"typeName": "subtitle",
"multiple": false,
"typeClass": "primitive",
"value": "Subtitle"
},
{
"typeName": "alternativeTitle",
"multiple": false,
"typeClass": "primitive",
"value": "Alternative Title"
},
{
"typeName": "alternativeURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://AlternativeURL.org"
},
{
"typeName": "otherId",
"multiple": true,
"typeClass": "compound",
"value": [
{
"otherIdAgency": {
"typeName": "otherIdAgency",
"multiple": false,
"typeClass": "primitive",
"value": "OtherIDAgency1"
},
"otherIdValue": {
"typeName": "otherIdValue",
"multiple": false,
"typeClass": "primitive",
"value": "OtherIDIdentifier1"
}
},
{
"otherIdAgency": {
"typeName": "otherIdAgency",
"multiple": false,
"typeClass": "primitive",
"value": "OtherIDAgency2"
},
"otherIdValue": {
"typeName": "otherIdValue",
"multiple": false,
"typeClass": "primitive",
"value": "OtherIDIdentifier2"
}
}
]
},
{
"typeName": "author",
"multiple": true,
"typeClass": "compound",
"value": [
{
"authorName": {
"typeName": "authorName",
"multiple": false,
"typeClass": "primitive",
"value": "LastAuthor1, FirstAuthor1"
},
"authorAffiliation": {
"typeName": "authorAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "AuthorAffiliation1"
},
"authorIdentifierScheme": {
"typeName": "authorIdentifierScheme",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "ORCID"
},
"authorIdentifier": {
"typeName": "authorIdentifier",
"multiple": false,
"typeClass": "primitive",
"value": "AuthorIdentifier1"
}
},
{
"authorName": {
"typeName": "authorName",
"multiple": false,
"typeClass": "primitive",
"value": "LastAuthor2, FirstAuthor2"
},
"authorAffiliation": {
"typeName": "authorAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "AuthorAffiliation2"
},
"authorIdentifierScheme": {
"typeName": "authorIdentifierScheme",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "ISNI"
},
"authorIdentifier": {
"typeName": "authorIdentifier",
"multiple": false,
"typeClass": "primitive",
"value": "AuthorIdentifier2"
}
}
]
},
{
"typeName": "datasetContact",
"multiple": true,
"typeClass": "compound",
"value": [
{
"datasetContactName": {
"typeName": "datasetContactName",
"multiple": false,
"typeClass": "primitive",
"value": "LastContact1, FirstContact1"
},
"datasetContactAffiliation": {
"typeName": "datasetContactAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "ContactAffiliation1"
},
"datasetContactEmail": {
"typeName": "datasetContactEmail",
"multiple": false,
"typeClass": "primitive",
"value": "ContactEmail1@mailinator.com"
}
},
{
"datasetContactName": {
"typeName": "datasetContactName",
"multiple": false,
"typeClass": "primitive",
"value": "LastContact2, FirstContact2"
},
"datasetContactAffiliation": {
"typeName": "datasetContactAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "ContactAffiliation2"
},
"datasetContactEmail": {
"typeName": "datasetContactEmail",
"multiple": false,
"typeClass": "primitive",
"value": "ContactEmail2@mailinator.com"
}
}
]
},
{
"typeName": "dsDescription",
"multiple": true,
"typeClass": "compound",
"value": [
{
"dsDescriptionValue": {
"typeName": "dsDescriptionValue",
"multiple": false,
"typeClass": "primitive",
"value": "DescriptionText1"
},
"dsDescriptionDate": {
"typeName": "dsDescriptionDate",
"multiple": false,
"typeClass": "primitive",
"value": "1000-01-01"
}
},
{
"dsDescriptionValue": {
"typeName": "dsDescriptionValue",
"multiple": false,
"typeClass": "primitive",
"value": "DescriptionText2"
},
"dsDescriptionDate": {
"typeName": "dsDescriptionDate",
"multiple": false,
"typeClass": "primitive",
"value": "1000-02-02"
}
}
]
},
{
"typeName": "subject",
"multiple": true,
"typeClass": "controlledVocabulary",
"value": [
"Agricultural Sciences",
"Business and Management",
"Engineering",
"Law"
]
},
{
"typeName": "keyword",
"multiple": true,
"typeClass": "compound",
"value": [
{
"keywordValue": {
"typeName": "keywordValue",
"multiple": false,
"typeClass": "primitive",
"value": "KeywordTerm1"
},
"keywordVocabulary": {
"typeName": "keywordVocabulary",
"multiple": false,
"typeClass": "primitive",
"value": "KeywordVocabulary1"
},
"keywordVocabularyURI": {
"typeName": "keywordVocabularyURI",
"multiple": false,
"typeClass": "primitive",
"value": "http://KeywordVocabularyURL1.org"
}
},
{
"keywordValue": {
"typeName": "keywordValue",
"multiple": false,
"typeClass": "primitive",
"value": "KeywordTerm2"
},
"keywordVocabulary": {
"typeName": "keywordVocabulary",
"multiple": false,
"typeClass": "primitive",
"value": "KeywordVocabulary2"
},
"keywordVocabularyURI": {
"typeName": "keywordVocabularyURI",
"multiple": false,
"typeClass": "primitive",
"value": "http://KeywordVocabularyURL2.org"
}
}
]
},
{
"typeName": "topicClassification",
"multiple": true,
"typeClass": "compound",
"value": [
{
"topicClassValue": {
"typeName": "topicClassValue",
"multiple": false,
"typeClass": "primitive",
"value": "Topic Classification Term1"
},
"topicClassVocab": {
"typeName": "topicClassVocab",
"multiple": false,
"typeClass": "primitive",
"value": "Topic Classification Vocab1"
},
"topicClassVocabURI": {
"typeName": "topicClassVocabURI",
"multiple": false,
"typeClass": "primitive",
"value": "https://TopicClassificationURL1.com"
}
},
{
"topicClassValue": {
"typeName": "topicClassValue",
"multiple": false,
"typeClass": "primitive",
"value": "Topic Classification Term2"
},
"topicClassVocab": {
"typeName": "topicClassVocab",
"multiple": false,
"typeClass": "primitive",
"value": "Topic Classification Vocab2"
},
"topicClassVocabURI": {
"typeName": "topicClassVocabURI",
"multiple": false,
"typeClass": "primitive",
"value": "https://TopicClassificationURL2.com"
}
}
]
},
{
"typeName": "publication",
"multiple": true,
"typeClass": "compound",
"value": [
{
"publicationCitation": {
"typeName": "publicationCitation",
"multiple": false,
"typeClass": "primitive",
"value": "RelatedPublicationCitation1"
},
"publicationIDType": {
"typeName": "publicationIDType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "ark"
},
"publicationIDNumber": {
"typeName": "publicationIDNumber",
"multiple": false,
"typeClass": "primitive",
"value": "RelatedPublicationIDNumber1"
},
"publicationURL": {
"typeName": "publicationURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://RelatedPublicationURL1.org"
}
},
{
"publicationCitation": {
"typeName": "publicationCitation",
"multiple": false,
"typeClass": "primitive",
"value": "RelatedPublicationCitation2"
},
"publicationIDType": {
"typeName": "publicationIDType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "arXiv"
},
"publicationIDNumber": {
"typeName": "publicationIDNumber",
"multiple": false,
"typeClass": "primitive",
"value": "RelatedPublicationIDNumber2"
},
"publicationURL": {
"typeName": "publicationURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://RelatedPublicationURL2.org"
}
}
]
},
{
"typeName": "notesText",
"multiple": false,
"typeClass": "primitive",
"value": "Notes1"
},
{
"typeName": "language",
"multiple": true,
"typeClass": "controlledVocabulary",
"value": [
"Abkhaz",
"Afar"
]
},
{
"typeName": "producer",
"multiple": true,
"typeClass": "compound",
"value": [
{
"producerName": {
"typeName": "producerName",
"multiple": false,
"typeClass": "primitive",
"value": "LastProducer1, FirstProducer1"
},
"producerAffiliation": {
"typeName": "producerAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "ProducerAffiliation1"
},
"producerAbbreviation": {
"typeName": "producerAbbreviation",
"multiple": false,
"typeClass": "primitive",
"value": "ProducerAbbreviation1"
},
"producerURL": {
"typeName": "producerURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://ProducerURL1.org"
},
"producerLogoURL": {
"typeName": "producerLogoURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://ProducerLogoURL1.org"
}
},
{
"producerName": {
"typeName": "producerName",
"multiple": false,
"typeClass": "primitive",
"value": "LastProducer2, FirstProducer2"
},
"producerAffiliation": {
"typeName": "producerAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "ProducerAffiliation2"
},
"producerAbbreviation": {
"typeName": "producerAbbreviation",
"multiple": false,
"typeClass": "primitive",
"value": "ProducerAbbreviation2"
},
"producerURL": {
"typeName": "producerURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://ProducerURL2.org"
},
"producerLogoURL": {
"typeName": "producerLogoURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://ProducerLogoURL2.org"
}
}
]
},
{
"typeName": "productionDate",
"multiple": false,
"typeClass": "primitive",
"value": "1003-01-01"
},
{
"typeName": "productionPlace",
"multiple": false,
"typeClass": "primitive",
"value": "ProductionPlace"
},
{
"typeName": "contributor",
"multiple": true,
"typeClass": "compound",
"value": [
{
"contributorType": {
"typeName": "contributorType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "Data Collector"
},
"contributorName": {
"typeName": "contributorName",
"multiple": false,
"typeClass": "primitive",
"value": "LastContributor1, FirstContributor1"
}
},
{
"contributorType": {
"typeName": "contributorType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "Data Curator"
},
"contributorName": {
"typeName": "contributorName",
"multiple": false,
"typeClass": "primitive",
"value": "LastContributor2, FirstContributor2"
}
}
]
},
{
"typeName": "grantNumber",
"multiple": true,
"typeClass": "compound",
"value": [
{
"grantNumberAgency": {
"typeName": "grantNumberAgency",
"multiple": false,
"typeClass": "primitive",
"value": "GrantInformationGrantAgency1"
},
"grantNumberValue": {
"typeName": "grantNumberValue",
"multiple": false,
"typeClass": "primitive",
"value": "GrantInformationGrantNumber1"
}
},
{
"grantNumberAgency": {
"typeName": "grantNumberAgency",
"multiple": false,
"typeClass": "primitive",
"value": "GrantInformationGrantAgency2"
},
"grantNumberValue": {
"typeName": "grantNumberValue",
"multiple": false,
"typeClass": "primitive",
"value": "GrantInformationGrantNumber2"
}
}
]
},
{
"typeName": "distributor",
"multiple": true,
"typeClass": "compound",
"value": [
{
"distributorName": {
"typeName": "distributorName",
"multiple": false,
"typeClass": "primitive",
"value": "LastDistributor1, FirstDistributor1"
},
"distributorAffiliation": {
"typeName": "distributorAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "DistributorAffiliation1"
},
"distributorAbbreviation": {
"typeName": "distributorAbbreviation",
"multiple": false,
"typeClass": "primitive",
"value": "DistributorAbbreviation1"
},
"distributorURL": {
"typeName": "distributorURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://DistributorURL1.org"
},
"distributorLogoURL": {
"typeName": "distributorLogoURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://DistributorLogoURL1.org"
}
},
{
"distributorName": {
"typeName": "distributorName",
"multiple": false,
"typeClass": "primitive",
"value": "LastDistributor2, FirstDistributor2"
},
"distributorAffiliation": {
"typeName": "distributorAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "DistributorAffiliation2"
},
"distributorAbbreviation": {
"typeName": "distributorAbbreviation",
"multiple": false,
"typeClass": "primitive",
"value": "DistributorAbbreviation2"
},
"distributorURL": {
"typeName": "distributorURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://DistributorURL2.org"
},
"distributorLogoURL": {
"typeName": "distributorLogoURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://DistributorLogoURL2.org"
}
}
]
},
{
"typeName": "distributionDate",
"multiple": false,
"typeClass": "primitive",
"value": "1004-01-01"
},
{
"typeName": "depositor",
"multiple": false,
"typeClass": "primitive",
"value": "LastDepositor, FirstDepositor"
},
{
"typeName": "dateOfDeposit",
"multiple": false,
"typeClass": "primitive",
"value": "1002-01-01"
},
{
"typeName": "timePeriodCovered",
"multiple": true,
"typeClass": "compound",
"value": [
{
"timePeriodCoveredStart": {
"typeName": "timePeriodCoveredStart",
"multiple": false,
"typeClass": "primitive",
"value": "1005-01-01"
},
"timePeriodCoveredEnd": {
"typeName": "timePeriodCoveredEnd",
"multiple": false,
"typeClass": "primitive",
"value": "1005-01-02"
}
},
{
"timePeriodCoveredStart": {
"typeName": "timePeriodCoveredStart",
"multiple": false,
"typeClass": "primitive",
"value": "1005-02-01"
},
"timePeriodCoveredEnd": {
"typeName": "timePeriodCoveredEnd",
"multiple": false,
"typeClass": "primitive",
"value": "1005-02-02"
}
}
]
},
{
"typeName": "dateOfCollection",
"multiple": true,
"typeClass": "compound",
"value": [
{
"dateOfCollectionStart": {
"typeName": "dateOfCollectionStart",
"multiple": false,
"typeClass": "primitive",
"value": "1006-01-01"
},
"dateOfCollectionEnd": {
"typeName": "dateOfCollectionEnd",
"multiple": false,
"typeClass": "primitive",
"value": "1006-01-01"
}
},
{
"dateOfCollectionStart": {
"typeName": "dateOfCollectionStart",
"multiple": false,
"typeClass": "primitive",
"value": "1006-02-01"
},
"dateOfCollectionEnd": {
"typeName": "dateOfCollectionEnd",
"multiple": false,
"typeClass": "primitive",
"value": "1006-02-02"
}
}
]
},
{
"typeName": "kindOfData",
"multiple": true,
"typeClass": "primitive",
"value": [
"KindOfData1",
"KindOfData2"
]
},
{
"typeName": "series",
"multiple": false,
"typeClass": "compound",
"value": {
"seriesName": {
"typeName": "seriesName",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesName"
},
"seriesInformation": {
"typeName": "seriesInformation",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesInformation"
}
}
},
{
"typeName": "software",
"multiple": true,
"typeClass": "compound",
"value": [
{
"softwareName": {
"typeName": "softwareName",
"multiple": false,
"typeClass": "primitive",
"value": "SoftwareName1"
},
"softwareVersion": {
"typeName": "softwareVersion",
"multiple": false,
"typeClass": "primitive",
"value": "SoftwareVersion1"
}
},
{
"softwareName": {
"typeName": "softwareName",
"multiple": false,
"typeClass": "primitive",
"value": "SoftwareName2"
},
"softwareVersion": {
"typeName": "softwareVersion",
"multiple": false,
"typeClass": "primitive",
"value": "SoftwareVersion2"
}
}
]
},
{
"typeName": "relatedMaterial",
"multiple": true,
"typeClass": "primitive",
"value": [
"RelatedMaterial1",
"RelatedMaterial2"
]
},
{
"typeName": "relatedDatasets",
"multiple": true,
"typeClass": "primitive",
"value": [
"RelatedDatasets1",
"RelatedDatasets2"
]
},
{
"typeName": "otherReferences",
"multiple": true,
"typeClass": "primitive",
"value": [
"OtherReferences1",
"OtherReferences2"
]
},
{
"typeName": "dataSources",
"multiple": true,
"typeClass": "primitive",
"value": [
"DataSources1",
"DataSources2"
]
},
{
"typeName": "originOfSources",
"multiple": false,
"typeClass": "primitive",
"value": "OriginOfSources"
},
{
"typeName": "characteristicOfSources",
"multiple": false,
"typeClass": "primitive",
"value": "CharacteristicOfSourcesNoted"
},
{
"typeName": "accessToSources",
"multiple": false,
"typeClass": "primitive",
"value": "DocumentationAndAccessToSources"
}
]
}
}
}
},
"headers": {
"Content-Type": "application/json"
}
}
Swagger/OpenAPI definition:
---
openapi: 3.0.0
info:
title: Deployed Resources
version: 1.0.0
servers: []
paths:
"/api/dataverses/{identifier}/datasets":
post:
operationId: createDatasetFromJsonLd
headers:
Content-Type: application/json
parameters:
- name: identifier
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
type: object
responses:
default:
description: Default Response.
content:
"*/*":
schema:
type: object
components:
schemas: {}
securitySchemas:
ApiKeyAuth:
type: apiKey
in: header
name: X-Dataverse-key
Swagger-Client usage:
async execute(parameters: { [paramName: string]: string | number }, requestBody: any): Promise<object> {
const {operationId} = this.openApiOperation
let response
const request: {
spec: object,
operationId: string,
headers?: { [headerName: string]: string },
parameters: { [paramName: string]: string | number },
body?: any
} = {
spec: this.bridge.openapiSchema,
operationId,
parameters
}
if (requestBody) {
request.body = JSON.parse(requestBody)
request.headers = {'Content-Type': 'application/json'}
}
try {
response = await SwaggerClient.execute(request)
console.log(response)
} catch (e) {
return Promise.reject(e)
}
Screenshots
How can we help?
Header and body of the built request are not included/sent
Adefey commented
same with FastAPI docs