-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use swagger generated code to interact with the zbMATH Rest API
- Loading branch information
1 parent
4a58ad7
commit 7939c79
Showing
4 changed files
with
12 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import swagger_client | ||
from zbmath_rest2oai.xml_writer import create_document | ||
|
||
api_instance = swagger_client.DocumentApi(swagger_client.ApiClient()) | ||
res = api_instance.get_document_by_zbmath_id_document_id_get(id="6383667") | ||
doc = res.result | ||
print(create_document(doc).toprettyxml()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from xml.dom import minidom # Create XML document | ||
|
||
from swagger_client import AllOfzbmathApiDataModelsDisplayDocumentsResultIDResult as Doc | ||
|
||
def create_document(json: dict): | ||
|
||
def create_document(doc: Doc): | ||
xmld = minidom.Document() | ||
root = xmld.createElement("root") | ||
root.appendChild(xmld.createTextNode( str ( json.get('result').get('id')) )) | ||
root.appendChild(xmld.createTextNode(str(doc.id))) | ||
xmld.appendChild(root) | ||
return xmld |