Skip to content

Schema Object namespaces #1362

Closed
Closed
@brendanclement

Description

@brendanclement

I am having the same problem described in #578 -- my use case has the possibility for definition names to clash. For example, you could have multiple User definitions inside a code base. I'm investigating the possibility of implementing (optional) namespaced Schema definitions and looking for feedback on this feature proposal

Some progress was made in #634 to extend legal character set in the 3.0 draft but this was removed in commit 840de94 .

I also found this thread asking for more granularity in specifying the namespace for model definitions: swagger-api/swagger-codegen#3915 - it was suggested that the OP could modify the generator and templates to achieve this

The following definitions will resolve correctly in the swagger ui editor and validator

definitions:
  core.Foobar:
    properties:
      bar:
        $ref : '#/definitions/core.Bar'
  core.Bar:
    properties:
      foo:
        type: string

but the swagger-codegen tooling does not currently honor the namespace. Using JavaCodegen as an example: when the definition above is translated into code class CoreFoobar and class CoreBar are emitted due to the name sanitization in DefaultCodegen.java
The example I gave above defined two normalized shapes, but I'm not sure how to handle namespaces defined in inline definitions (a de-normalized schema). e.g. Which namespace would the child object belong to?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions