question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Questions about org.eclipse.microprofile.openapi.models.PathItem

See original GitHub issue

I am new to the Microprofile project, I hope this is the appropriate channel to start a discussion.

How definitive are the model interfaces introduced with version MicroProfile release 3.1? I understand that Swagger Core was used as reference, but maybe some stuff can be improved when establishing a standard.

Today I have worked a lot with PathItem and Operation (I work with swagger-core) and I was curious to see how you guys did solve this.

Here 2 questions about org.eclipse.microprofile.openapi.models.PathItem.

Thank you in advance for the discussion.


Question 1: why are the convenience methods that provides all operations as list or as map called readOperations() and readOperationsMap():

https://github.com/eclipse/microprofile-open-api/blob/bffd7ace546bd964cb46d29dcf2114c8ac28fe80/api/src/main/java/org/eclipse/microprofile/openapi/models/PathItem.java#L266-L278

I like the way the Kaizen-Parser solves this by providing a map (they do not have the enum for HTTP operation type):

	Map<String, Operation> getOperations();

(source)

If we take the best of both words:

Map<PathItem.HttpMethod, Operation> getOperations();

With the constraint that the returned Map should never be null and that the map is a read-only access to the operations. (could be indicated in the Javadoc)

If you just want the collection of operations getOperations().values() can be called. I do not think that a method returning List<Operation> is requested.


Question 2: In Swagger-Core the String path of an PathItem is an important information that belongs in my opinion to the PathItem object, but that is missing the Operation object.

To access to this information you need the corresponding Entry<String, PathItem> of the Paths map holding the PathItem.

Because this information is not present, you need always to pass it with in each PathItem instance in of your methods:

void printOperationsInfo(String path, PathItem path);

Or to have your own holder class:

static class PathItemWithPath {
    final String pathString;
    final PathItem path;

    public PathItemWithPath(final String pathString, final PathItem path) {
        super();
        this.pathString = pathString;
        this.path = path;
    }

The Kaizen-Parser Model did solve this with:

	String getPathString();

(source)

Maybe the wording is not ideal, but the information is really important when you manipulate PathItem instances.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
arthurdmcommented, Jul 10, 2018

hey @jmini - welcome to MicroProfile and thanks a lot for your feedback! It’s really cool to merge best practices from industry leaders like Kaizen and Swagger, so definitely a good direction.

I agree with both your suggestions. For #1 I suspect that’s a historic serialization/deserialization issue where there wasn’t a field called operations so getOperations was ruled out - but whatever historic reasoning was used, I don’t see any issues with the proposal.

For #2, we have Paths which uses name as the path string, so I would suggest we add String getName(); just for consistency with its parent model.

If you would like to submit a PR for this, I will gladly review.

Thanks.

0reactions
jminicommented, Aug 30, 2018

New issue: https://github.com/eclipse/microprofile-open-api/issues/264

the issue is only a draft, I never took the time to investigate the proposed concept completely. But I am sure that the concept is necessary. It simplifies the manipulation code a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PathItem (MicroProfile OpenAPI API)
Describes the operations available on a single path. A Path Item MAY be empty, due to security constraints. In that case the path...
Read more >
Override ref value in smallrye microprofile using custom ...
I'm trying to override ref value in schema for microprofile health check API in quarkus application. I followed the below link Smallrye open...
Read more >
MicroProfile 2.1 :: Open Liberty Docs
... Method in interface org.eclipse.microprofile.openapi.models.PathItem ... objects for the discovered beans, but before detecting deployment problems.
Read more >
eclipse/microprofile-open-api
Eclipse MicroProfile OpenAPI · The spec APIs are composed of annotations, models, and programming interfaces. · The spec documentation outlines the rules and ......
Read more >
Jersey 2.37 User Guide - GitHub Pages
Reusing Jersey implementation in your custom application model; 4.3. ... Jetty HTTP container supports injection of Jetty-specific org.eclipse.jetty.server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found