Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Symfony-api-doc-generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
Symfony-api-doc-generator
Commits
302d3f35
Commit
302d3f35
authored
Aug 17, 2022
by
Jonas Leder
Browse files
Options
Downloads
Patches
Plain Diff
fix indent sometimes wrong
parent
aec5bf5c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Symfony-api-doc-generator/Program.cs
+8
-8
8 additions, 8 deletions
Symfony-api-doc-generator/Program.cs
with
8 additions
and
8 deletions
Symfony-api-doc-generator/Program.cs
+
8
−
8
View file @
302d3f35
...
...
@@ -19,7 +19,7 @@ while (emptyLines < 2)
input
+=
line
;
}
string
ParseJsonArray
(
JArray
json
,
int
indent
=
0
)
string
ParseJsonArray
(
JArray
json
,
int
indent
=
1
)
{
string
childDoc
=
""
;
if
(
json
.
Count
>
0
)
...
...
@@ -37,10 +37,10 @@ string ParseJsonArray(JArray json, int indent = 0)
childDoc
=
GenerateIndent
()
+
"type=\"boolean\",\n"
+
GenerateIndent
()
+
"example=\""
+
firstElement
.
ToString
().
ToLower
()
+
"\"\n"
;
break
;
case
"Object"
:
childDoc
=
GenerateIndent
()
+
"type=\"object\",\n"
+
GenerateIndent
()
+
ParseJsonObject
((
JObject
)
firstElement
,
indent
+
1
)
+
"\n"
;
childDoc
=
GenerateIndent
()
+
"type=\"object\",\n"
+
ParseJsonObject
((
JObject
)
firstElement
)
+
"\n"
;
break
;
case
"Array"
:
childDoc
=
GenerateIndent
()
+
"type=\"array\",\n"
+
GenerateIndent
()
+
ParseJsonArray
((
JArray
)
firstElement
,
indent
+
1
)
+
"\n"
;
childDoc
=
GenerateIndent
()
+
"type=\"array\",\n"
+
ParseJsonArray
((
JArray
)
firstElement
)
+
"\n"
;
break
;
}
}
...
...
@@ -49,7 +49,7 @@ string ParseJsonArray(JArray json, int indent = 0)
return
IndentString
(
apiDocs
,
indent
);
}
string
ParseJsonObject
(
JObject
json
,
int
indent
=
0
)
string
ParseJsonObject
(
JObject
json
,
int
indent
=
1
)
{
string
apiDocs
=
""
;
foreach
(
JProperty
token
in
json
.
Children
())
...
...
@@ -69,10 +69,10 @@ string ParseJsonObject(JObject json, int indent = 0)
childDoc
=
GenerateIndent
()
+
"type=\"boolean\",\n"
+
GenerateIndent
()
+
"example=\""
+
value
.
ToString
().
ToLower
()
+
"\"\n"
;
break
;
case
"Object"
:
childDoc
=
GenerateIndent
()
+
"type=\"object\",\n"
+
GenerateIndent
()
+
ParseJsonObject
((
JObject
)
value
,
indent
+
1
)
+
"\n"
;
childDoc
=
GenerateIndent
()
+
"type=\"object\",\n"
+
ParseJsonObject
((
JObject
)
value
)
+
"\n"
;
break
;
case
"Array"
:
childDoc
=
GenerateIndent
()
+
"type=\"array\",\n"
+
GenerateIndent
()
+
ParseJsonArray
((
JArray
)
value
,
indent
+
1
)
+
"\n"
;
childDoc
=
GenerateIndent
()
+
"type=\"array\",\n"
+
ParseJsonArray
((
JArray
)
value
)
+
"\n"
;
break
;
}
...
...
@@ -87,10 +87,10 @@ string ParseJson(string json, int indent = 0)
if
(
Regex
.
IsMatch
(
json
,
@"^\s\["
))
{
JArray
jsonArr
=
JArray
.
Parse
(
json
);
return
"OA\\JsonContent(\n type=\"array\",\n"
+
ParseJsonArray
(
jsonArr
,
indent
+
1
)
+
"),"
;
return
"OA\\JsonContent(\n type=\"array\",\n"
+
ParseJsonArray
(
jsonArr
)
+
"),"
;
}
JObject
jsonObj
=
JObject
.
Parse
(
json
);
return
"OA\\JsonContent(\n type=\"object\",\n"
+
ParseJsonObject
(
jsonObj
,
indent
+
1
)
+
"),"
;
return
"OA\\JsonContent(\n type=\"object\",\n"
+
ParseJsonObject
(
jsonObj
)
+
"),"
;
}
string
IndentString
(
string
stringToIndent
,
int
indent
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment