Code Monkey home page Code Monkey logo

Comments (21)

MikeRalphson avatar MikeRalphson commented on May 30, 2024

This is true. How are you generating the source markdown?

from shins.

neverlan avatar neverlan commented on May 30, 2024

With widdershins, from an openapi file

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

And are you using custom templates? You need to ensure the link anchor ids are unique yourself, which you can do by replacing the clashing ## anchors with

# Authentication
<h2 id="authentication-default">Default</h2>

Please let me know if it's an anchor from a built-in template (or hardcoded) and I'll fix it.

from shins.

neverlan avatar neverlan commented on May 30, 2024

I am using the built-in templates, not custom ones :)

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

OK, is 'Authorization' a tag in your OpenAPI definition? I'm not sure where '## Default' is coming from... They're not duplicated operationIds are they?

from shins.

neverlan avatar neverlan commented on May 30, 2024

I am converting multiples openapi files into one documentation.

#Authentication and #Authorization are the services names
I don't have an "Authorization" tag in my OpenAPI file.

I don't know why but widdershins create a "Default" tag with methods that don't need authentification (security tag), and a "Service name" tag with methods with auth, resulting in something like that:

# Invoices (service name)
## Default
### operationId1
### operationId2
### operationId3
## Invoives (service name)
### opeartionId4 (auth)
### operationId5 (auth)

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

How are you converting the multiple OpenAPI definitions into one? How do the service names end up as level-one headers?

Widdershins creates a 'Default' tag for any operations which don't have a tag - this is so they have somewhere to go in the Table Of Contents (TOC). If you are pre- or post-processing the markdown to adjust the tags, you'll have to take this into account by modifying the Default tags to include the service name in the id property as above.

from shins.

neverlan avatar neverlan commented on May 30, 2024

I am converting each OpenAPI files with widdershins, then with a regex I remove markdown header, i convert # to ## and ## to ###.

Then I manually insert my header, and I join each converted markdown prefixed with # Service Name

Thanks for the tips about "Default" tag, I will add tags for methods that don't have ones in my openapi files

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

Ok, now I think I understand! The problem is your script isn't making the duplicate # Default headers unique, but Widdershins doesn't know any 'service name' to use to make them unique either.

I think we have a few options:

  • create an option for Widdershins to pass in a service-name for each OpenAPI definition
  • use the info.title of the API (with spaces removed) as a prefix for the id property
  • use an OpenAPI specification (vendor) extension like x-service-name
  • use a guid or similar - has disadvantage it will change every time the conversion is run

Do you see other advantages/disadvantages to any of these?

BTW, are you using the new --headings option for Widdershins to enable <h3>s to appear in the TOC?

from shins.

neverlan avatar neverlan commented on May 30, 2024

I think the info.title is the easier / faster to implement

Yeah, I am using the --headings option on widdershins

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

One other option is to make sure every operation in your OpenAPI definitions has a tag, and make the 'default' tags unique across all definitions...

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

Ok - testing the change... Please consider adding your script / solution to the Widdershins wiki in case anyone else is working with micro-service definitions.

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

Should be fixed in Widdershins v2.2.10 - please let me know if not.

from shins.

neverlan avatar neverlan commented on May 30, 2024

I am still getting the issue:

<h2 id="default">Default</h2>

from shins.

neverlan avatar neverlan commented on May 30, 2024

Also widdershins still create an empty "Default" section even if all paths get a tag field

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

Hmm, I'm not seeing that with either the specs/petstore.json definition (where every operation has a tag) or specs/xkcd.yaml where 'Default' is included but the heading is now:

<h1 id="XKCD-default">Default</h1>

from shins.

neverlan avatar neverlan commented on May 30, 2024

Looks like it is a problem with the published package. When I pull master from widdershins "Default" id is ok, and not on 2.2.10

from shins.

neverlan avatar neverlan commented on May 30, 2024

Ok so, there is still a problem with h2 / h3 fields that have the same name:

# Authentication
### Health check
# Authorization
### Health check

Click on the second one "Heal check" will link to the first one

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

The only difference between GitHub master and v2.2.10 was (what should have been) an unrelated commit. Anyway, I've published v2.2.11 now containing that commit.

If your OpenAPI definitions contain clashing tags, I think you need to do the replacement of the ## and ### headings with anchor tags in your script. If I do it for all TOC entries it will break peoples' bookmarks.

It will be easier to adjust the headings in v3.x of Widdershins, which should be released later this month.

from shins.

neverlan avatar neverlan commented on May 30, 2024

Thanks a lot :)

from shins.

MikeRalphson avatar MikeRalphson commented on May 30, 2024

Closing this here, as I think it is really a widdershins issue. Please feel free to carry on the conversation on Mermade/widdershins#61

from shins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.