Add primitive support for rendering api v3 jira docs
This commit is contained in:
parent
563ec7bd2f
commit
fa387c5546
9 changed files with 224 additions and 12 deletions
|
@ -18,7 +18,7 @@ impl JiraCommand for IssueCreateCommand {
|
|||
const REQUEST_TYPE: JiraRequestType = JiraRequestType::Create;
|
||||
|
||||
fn endpoint(&self) -> String {
|
||||
"/rest/api/2/issue".to_string()
|
||||
"/rest/api/3/issue".to_string()
|
||||
}
|
||||
|
||||
fn request_body(&self) -> Option<&Self::TPayload> {
|
||||
|
|
|
@ -20,7 +20,7 @@ impl JiraCommand for IssueGetCommand {
|
|||
const REQUEST_TYPE: JiraRequestType = JiraRequestType::Read;
|
||||
|
||||
fn endpoint(&self) -> String {
|
||||
format!("/rest/api/2/issue/{}", self.key)
|
||||
format!("/rest/api/3/issue/{}", self.key)
|
||||
}
|
||||
|
||||
fn request_body(&self) -> Option<&Self::TPayload> {
|
||||
|
|
|
@ -20,7 +20,7 @@ impl JiraCommand for SearchCommand {
|
|||
const REQUEST_TYPE: JiraRequestType = JiraRequestType::Read;
|
||||
|
||||
fn endpoint(&self) -> String {
|
||||
"/rest/api/2/search".to_string()
|
||||
"/rest/api/3/search".to_string()
|
||||
}
|
||||
|
||||
fn request_body(&self) -> Option<&Self::TPayload> {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
pub mod doc;
|
||||
pub mod issue;
|
||||
pub mod issue_request;
|
||||
pub mod search;
|
||||
|
|
90
crates/libjirac/src/entities/doc.rs
Normal file
90
crates/libjirac/src/entities/doc.rs
Normal file
|
@ -0,0 +1,90 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Doc {
|
||||
pub version: i32,
|
||||
pub content: Vec<DocNode>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(tag = "type", content = "content")]
|
||||
pub enum DocNode {
|
||||
Paragraph(Vec<DocTextNode>),
|
||||
BulletList(Vec<DocNode>),
|
||||
ListItem(Vec<DocNode>),
|
||||
OrderedList(Vec<DocNode>),
|
||||
Rule,
|
||||
Heading(Vec<DocTextNode>),
|
||||
MediaSingle(Vec<DocTextMarker>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(tag = "type")]
|
||||
pub enum DocTextNode {
|
||||
Text(DocTextNodeContent),
|
||||
HardBreak,
|
||||
InlineCard(DocInlineCard),
|
||||
Mention(DocMention),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DocTextNodeContent {
|
||||
pub text: String,
|
||||
pub marks: Option<Vec<DocTextMarker>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(tag = "type", content = "attrs")]
|
||||
pub enum DocTextMarker {
|
||||
Link(DocTextMarkerLink),
|
||||
Strong,
|
||||
Code,
|
||||
Media(DocMedia),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DocTextMarkerLink {
|
||||
pub href: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(tag = "type")]
|
||||
pub enum DocMedia {
|
||||
File(DocMediaFile),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DocMediaFile {
|
||||
pub id: String,
|
||||
pub alt: String,
|
||||
pub collection: String,
|
||||
pub height: i32,
|
||||
pub width: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DocInlineCard {
|
||||
pub attrs: DocInlineCardAttrs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DocInlineCardAttrs {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DocMention {
|
||||
pub attrs: DocMentionAttrs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DocMentionAttrs {
|
||||
pub id: String,
|
||||
pub text: String,
|
||||
pub local_id: String,
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
use crate::entities::doc::Doc;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
|
@ -11,7 +12,7 @@ pub struct JiraIssue {
|
|||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct JiraIssueResponseFields {
|
||||
pub summary: String,
|
||||
pub description: Option<String>,
|
||||
pub description: Option<Description>,
|
||||
pub status: Status,
|
||||
pub created: chrono::DateTime<chrono::Utc>,
|
||||
pub priority: Priority,
|
||||
|
@ -24,6 +25,13 @@ pub struct JiraIssueResponseFields {
|
|||
pub votes: Votes,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Description {
|
||||
Doc(Doc),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Status {
|
||||
pub name: String,
|
||||
|
@ -63,7 +71,7 @@ pub struct Comment {
|
|||
pub href: String,
|
||||
pub id: String,
|
||||
pub author: Person,
|
||||
pub body: String,
|
||||
pub body: Doc,
|
||||
#[serde(rename = "updateAuthor")]
|
||||
pub update_author: Person,
|
||||
pub created: chrono::DateTime<chrono::Utc>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue